i hope you can help me with this. i am new into android
i am trying to solve this problem but i couldnt
the problem when i declared this method
public void onNavigationDrawerItemSelected(int position) {
// slide menue declaration
Fragment fragment = null;
switch (position) {
case 0:
fragment = new menu1_Fragment();
break;
case 1:
fragment = new menu2_Fragment();
break;
case 2:
fragment = new menu3_Fragment();
break;
default:
break;
}
it give me an error saying required android.support.v4.app.fragment
Check your imports at the beginning of your classes. I guess there will be a import android.app.Fragment;. Change it to import android.support.v4.app.Fragment;. Maybe the error is caused by the menuX_Fragments which extend android.app.Fragment instead of the support fragment.
You can use import android.support.v4.app.Fragment for developing apps for lower android versions, fragments are introduced in Android 3.0.
Decide for one version of fragments and use it everywhere. I guess you mixed it up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With