Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

required android.support.v4.app.fragment

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

like image 807
user3821979 Avatar asked Mar 19 '15 15:03

user3821979


1 Answers

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.

like image 79
RuNaWaY87 Avatar answered Sep 28 '22 01:09

RuNaWaY87