Requires android .support.v4.app.fragment

I hope you can help me. I'm new to android

I am trying to solve this problem, but I could not

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 gives me an error saying that android .support.v4.app.fragment is required

+10
android import android-fragments
source share
2 answers

Check your import at the beginning of your classes. I assume there will be import android.app.Fragment; . Change it to import android.support.v4.app.Fragment; . Perhaps the error is caused by menuX_Fragments, which extend the android.app.Fragment file instead of the support fragment.

You can use import android.support.v4.app.Fragment to develop applications for lower versions of Android, fragments are presented in Android 3.0.

Solve for one version of the snippets and use it everywhere. I think you mixed it up.

+31
source share

I had the same problem just watch this video

https://www.youtube.com/watch?v=8bSkludFfG0

-one
source share

All Articles