I have onclicklistener that works. I am trying to launch a new fragment from the button click on the list view. Right now, the fragment does not launch. However, the emulator we
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();
}