[英]incompatible type erros in android studio
I received an error that says: 我收到一条错误消息:
Incompatible Types. 不兼容的类型。
Required: android.support.v4.app.Fragment 必需:android.support.v4.app.Fragment
Found: com.ortegapatriciaa.enventer._7_ViewClient_UpcomingEvents" 找到:com.ortegapatriciaa.enventer._7_ViewClient_UpcomingEvents“
Here is my code: 这是我的代码:
public class PagerAdapter extends FragmentStatePagerAdapter {
int mNumOfTabs;
public PagerAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
_7_ViewClient_UpcomingEvents tab1 = new _7_ViewClient_UpcomingEvents();
return tab1;
case 1:
_7_ViewClient_MyEvents tab2 = new _7_ViewClient_MyEvents();
return tab2;
default:
return null;
}
}
@Override
public int getCount() {
return mNumOfTabs;
}
}
public class _7_ViewClient_UpcomingEvents {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.activity_7_view_client_upcoming_events, container, false);
}
}
This is how your classes should look like : 这是您的类的外观:
public class _7_ViewClient_UpcomingEvents extends android.support.v4.app.Fragment
_7_ViewClient_MyEvents extends android.support.v4.app.Fragment
Both the classes should be subclasses Fragment
这两个类都应该是子类Fragment
Also, I would recommend to follow a better naming convention. 另外,我建议遵循更好的命名约定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.