ViewPage Fragment disappear when reload again

前端 未结 5 1253
执笔经年
执笔经年 2021-02-06 05:20

The following is layout

test.xml





        
5条回答
  •  一向
    一向 (楼主)
    2021-02-06 05:50

    Try to add this lines in your code:

    public int getItemPosition(Object object) {
       return POSITION_NONE;
    }
    

    and Add the below lines

    pager.setOnPageChangeListener(new OnPageChangeListener() {
         @Override
         public void onPageSelected(int position) {
              ... anything you may need to do to handle pager state ...
              adapter.notifyDataSetChanged(); //this line will force all pages to be loaded fresh when changing between fragments
         }
    

    Under

    pager.setAdapter(adapter);
    

    Hope this may help you!

提交回复
热议问题