Note that there are some explanatory texts on larger screens.

plurals
  1. POFool-proof way to handle Fragment on orientation change
    primarykey
    data
    text
    <pre><code>public class MainActivity extends Activity implements MainMenuFragment.OnMainMenuItemSelectedListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction(); // add menu fragment MainMenuFragment myFragment = new MainMenuFragment(); fragmentTransaction.add(R.id.menu_fragment, myFragment); //add content DetailPart1 content1= new DetailPart1 (); fragmentTransaction.add(R.id.content_fragment, content1); fragmentTransaction.commit(); } public void onMainMenuSelected(String tag) { //next menu is selected replace existing fragment } </code></pre> <p>I have a need to display two list views side by side ,menu on left and its content on right side,by default the first menu is selected and its content is displayed on right side.The Fragment that displays content is as below</p> <pre><code>public class DetailPart1 extends Fragment { ArrayList&lt;HashMap&lt;String, String&gt;&gt; myList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); ListAdapter adap; ListView listview; @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if(savedInstanceState!=null){ myList = (ArrayList)savedInstanceState.getSerializable("MYLIST_obj"); adap = new LoadImageFromArrayListAdapter(getActivity(),myList ); listview.setAdapter(adap); }else{ //get list and load in list view getlistTask = new GetALLListTasks().execute(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.skyview_fragment, container,false); return v; } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable("MYLIST_obj", myList ); } } </code></pre> <p>The onActivityCreated and onCreateView is called <strong>twice</strong> ,there are many examples out there using fragments ,hence i am beginner in this segment i am unable relate the example with my problem .I need fool proof way to handle orientation change in a better way.I have NOT declared android:configChanges in manifest file ,i need the activity destroy and recreate so that i can use different layout in landscape mode.Please help to a workaround </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload