添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
I have 3 fragments attached with viewpager.
I have a single database and all three fragments data is connected to each other so if i make any change in fragment 1 & it should also be reflected in fragment 2(when it is visible to user)
previously i was using
 @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if(isVisibleToUser){
            getFragmentManager().beginTransaction().detach(this).attach(this).commit();
but setUserVisibleHint is deprecated so i need to replace it but cloudn't find proper solution.
I tried to used "detach().attach()" in onResume but it goes to infinite loop then.
Note: i tried to use "notifyDataSetChanged()" instead of detach.attach but it doesn't work properly and takes time to reflect data.
I tried to recreate activity but it push the recyclerView on first item. I want my recyclerView to be show on the same state where it previously was like if it was on item no 24 before leaving it then whenever user comeback on same fragment by doing detach.attach data is refreshed and recyclerView is on same position.
Please tell me the alternative solution for detach.attach on every desired fragment is visible to user.
Thanks