I want to add FileChooser(← I use this) to my app(my Main Activity extends ActionBarActivity).And I tried to change FileChooser to Fragment or ListFragment. Because I want pages can be selected by user(I use drawer to select Fragment).
My app's structure like the picture:enter link description here(because i can't post pictuer here)
But if I change to Fragment it didn't work. If I change to ListFragment it will work ,but It displayed over last fragment like the picture:it beside the picture of above(please click the link again,because i can't post so many link)
AndroidManifest.xml: android:minSdkVersion="11" android:targetSdkVersion="21"
My selectitem() code:
private void selectItem(int position) {
Fragment fragment = null;
switch (position) {
case 0:
Toast.makeText(getApplicationContext(),"case 0", Toast.LENGTH_SHORT).show();
fragment = new First();
break;
case 1:
Toast.makeText(getApplicationContext(),"case 1", Toast.LENGTH_SHORT).show();
fragment = new Second();
break;
case 2:
Toast.makeText(getApplicationContext(),"case 2", Toast.LENGTH_SHORT).show();
fragment = new Third();
break;
}
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment);
fragmentTransaction.addToBackStack("home");
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
fragmentTransaction.commit();
mDrawerList.setItemChecked(position, true);
setTitle(mPlanetTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
}
My question:
- How to change FileChooser from ListActivity to Fragment or ListFragment?(If someone has other methods, please tell me)
- How can I display it after user click button(in First's layout) and will not see last Fragment's layout? (if it can change to Fragment or ListFragment)
- continue2 , How to Transfer data to other fragments?
- Which is better to import (in ActionBarActivity)? (android.app.Fragment or android.support.v4.app.Fragment)
Thanks for everyone who read my question