TabsPagerAdapter类错误“类型不匹配”

时间:2014-03-15 10:30:18

标签: android layout android-fragments

我在TabsPagerAdapter类中遇到问题,显示错误... Type mismatch: cannot convert from MapActivity to Fragment帮我解决了这个问题。

注意

class MapActivity extends FragmentActivity

class Directions extends Fragment

class places extends Fragment 

TabsPagerAdapter类是

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;




public class TabsPagerAdapter extends FragmentPagerAdapter {

public TabsPagerAdapter(FragmentManager fm) {
    super(fm);
}

@Override
public Fragment getItem(int index) {

    switch (index) {
    case 0:
        // Map fragment activity
        return new MapActivity();
    case 1:
        // Directions fragment activity
        return new Directions();
    case 2:
        // Places fragment activity
        return new Places();
    }

    return null;
}

@Override
public int getCount() {
    // get item count - equal to number of tabs
    return 3;
}

}   

0 个答案:

没有答案