android - Fragment Transaction Commit: State Loss in OnClick? -
i still dont seem state loss error when commiting fragment. have listview onclicklistener:
public void onlistitemclick(listview l, view v, int position, long id) { switch (position) { case 0: fragmenttabactivity.addfragments(maintabhostactivity.gettabnames()[0], new openerlocationlistfragment(), true); break; } }
and addfragments method:
public void addfragments(string tabname, fragment fragment, boolean add) { if (add) { hmaptabs.get(tabname).add(fragment); } fragmentmanager manager = getsupportfragmentmanager(); fragmenttransaction ft = manager.begintransaction(); ft.replace(android.r.id.tabcontent, fragment); ft.commit(); }
how can lose state in short time frame? can understand why happens in asynctasks should different here (other allowing state loss)? has suggestions?
Comments
Post a Comment