in my app i need to switch between fragments when different items on the navigation drawer are clicked. I created a new method DisplayFragment for it. Here is the code:
private void DisplayFragment(int position)
{
Fragment fragment = null;
switch (position){
case 0:
fragment = new Fragment1();
break;
case 1:
fragment = new Fragment2();
break;
case 2:
fragment = new Fragment3();
break;
case 3:
fragment = new Fragment4();
break;
if(fragment!= null)
this.getFragmentManager().beginTransaction().replace(R.id.frame_container,fragment()).commit();
}
it shows an error for "fragment element in above line as follows " wrong second argument type found android.support.v4.app.Fragment; required android.app.Fragment;"
i tried changing the import from android.support.v4.app.Fragment to android.app.Fragment; but it then shows an error for Fragment fragment = null statement. what am i doing wrong?