The layout of the sliding display of multiple fragment for my project with Tablayout+viewpage
The first one to use the Recyclerview, found Recyclerviewadapter call notifydatasetchanged when nothing came out, because the other several fragment are not listed, So you've debugged the recyclerviewadapter in this fragment, and the following is the method that you follow to get the data.
private void SetData () {
if (adapter==null) {
Adapter = new Popularitytendadapter (mcontext,datalists);
Recyclerview.setadapter (Adapter);//recyclerview Settings Adapter
Adapter.setonitemclicklistener (New Onrecyclerviewitemclicklistener () {
@Override
public void Onitemclick (view view, int position) {
Toast.maketext (Mcontext, "clicked" +position, Toast.length_short). Show ();
}
});
Recyclerview.setnestedscrollingenabled (FALSE);
}else{
Refreshing data
Adapter.notifydatasetchanged ()//
}
}
The initial load is OK, but when you slide back from the other fragment, the content is not displayed, the adapter.notifydatasetchanged () is called, but there is no display.
On the Internet read this for the brothers analysis of the http://blog.csdn.net/csdn_lqr/article/details/61925004, selected the second kind, In fact, and ListView in the GetView in the Contentview price to determine whether the operation is empty, the difference is not to avoid repeating the view, but related to the fragment life cycle, the data datalists is unchanged, But the Recyclerview changed.
So it's OK to judge in Oncreateview whether the root view price is empty.