MuPDF for Android: Option for fragment instead Activity

前端 未结 2 1479
深忆病人
深忆病人 2021-01-05 17:38

In my existing android app, Im using MuPDF, which i ported with help of this doc. Now when i want to open pdf files inside activity i use : Uri uri = Uri.parse(path);

<
2条回答
  •  借酒劲吻你
    2021-01-05 18:10

    Converting activity to fragment :

    public class a extend activity{
    
         public void oncreate(Bundle Saveinstance)
         {
         super.oncreate(saveinstance);
         setcontentview(r.layout.xyz);
         }    
        }
    

    Converting ... :

      public class a extend fragment{
    
    
     public void onstart()
     {
     super.onstart();
    
     }   
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub
    
    
        return inflater.inflate(com.example.login.R.layout.fragment, container, false);
    
    } 
    }
    

    If you have a function or you wanna make a Toast , and you have xyz.this replace him with getActivity()

    Toast.makeText(xyz.this, e.getMessage(),Toast.LENGTH_LONG).show(); 
    Toast.makeText(getActivity(), e.getMessage(),Toast.LENGTH_LONG).show();
    

提交回复
热议问题