How to call a fragment from BaseAdapter Class Android?

前端 未结 7 664
走了就别回头了
走了就别回头了 2020-12-17 03:38

I want to call a Fragement from my BaseAdapter Class. In this class I have button on click of which I want to call the new fragment, but I am not able to get this. I have to

7条回答
  •  臣服心动
    2020-12-17 03:50

    FragmentManager manager = ((AppCompatActivity) 
    context).getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = manager.beginTransaction();
                fragmentTransaction.replace(R.id.content_frame, new AlbumFragment());
                fragmentTransaction.addToBackStack(null);
                fragmentTransaction.commit();
    

提交回复
热议问题