Fragment won't launch

只愿长相守 提交于 2019-12-02 08:19:24

change this line

Intent intent =new Intent(eventList.this, fr.getClass());

to:

fragmentTransaction.commit;

and better replace fragment in container ,

fragmentTransaction.replace(R.id.page, fr);

You should be using commit() to start your transaction, not an Intent(), you also want to use replace() not add():

 public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l)
{
    //Assuming that this creates a new fragment
    Fragment fr = new event_description();
    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    fragmentTransaction.replace(R.id.page, fr, "TAG ID");
    fragmentTransaction.commit();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!