简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM