我在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;
}
}