Reprint Please specify source: http://blog.csdn.net/djy1992/article/details/46674169
@author Dujinyang
It's a rare time to write a blog.
Fragment although easy to use, but the individual still feel the pros and cons.
Most of the online said switching state, there are quite a number of problems,
There are many kinds of solutions.
The first kind of situation that is often encountered:
if (Rootview = = null) Rootview = Inflater.inflate (R.layout.fragment_home, Container,false); ViewGroup parent = (ViewGroup) rootview.getparent (); if (parent = null) Parent.removeview (Rootview); Initview (Rootview); return rootview;
The second type is the ListView:
The same goes for the adapter inside the ListView,
@Overridepublic view GetView (int position, view Convertview, ViewGroup parent) {view View=convertview;if (view==null) { View=new TextView (Getactivity (). Getapplicationcontext ());} ((TextView) view). SetText ("This is the section" +position+ "test Data");((TextView) view). settextsize; return view;}
The third kind of estimate is less people encounter:
Tossing the afternoon, because of the demand relationship, you need to add Viewpager+tabhost + animation in the tab first option,
In fact, it took a long time to find that the original is the animation layer, did not save, but because it is the reason for the picture, and can not save the location,
The test has been solved for a long time.
Onpagechangelistener inside the rewritten Onpageselected,switch selector in the animation layer output by its own arg0,
Add one more option to each tab, save as a location, not in the outer record position, because there will be a bug. The position is calculated by the position of each tab, so that the position information generated by the slide can be resolved.
Hope to be useful to everyone. If there are other incurable diseases, can leave a message or add me Q.
Reprint Please specify source: http://blog.csdn.net/djy1992/article/details/46674169
Android fragment+ Fragmenttabhost+viewpager Switch state does not save the issue