我的片段不能被转换为android.support.v4.app.Fragment [英] My fragment cannot be cast to android.support.v4.app.Fragment
本文介绍了我的片段不能被转换为android.support.v4.app.Fragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个非常简单的片段来测试我的应用程序,我得到了以下错误消息:
I created a very simple fragment to test my app and I got the following error message:
03-31 16:04:39.834: E/AndroidRuntime(7860): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.team3.domore/com.team3.domore.TabActivity}: java.lang.ClassCastException: com.team3.domore.SomeFrag cannot be cast to android.support.v4.app.Fragment
我的片段是非常简单的...
My fragment is really simple...
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class SomeFrag extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.alarm_frag, container, false);
}
@Override
public void onStart() {
super.onStart();
}
}
请帮忙......我一直在努力奋斗着这个了近两个小时。
Please help...I've been struggling with this for almost two hours..
编辑:我是pretty的肯定,我称这个片段(扩展FragmentActivity一个活动)是工作......眼前这个片断部分是不工作...
I'm pretty sure where I called this fragment (an activity that extends FragmentActivity) is working... just this fragment part is not working...
推荐答案
您 SomeFrag
扩展
android.app.Fragment
如在进口说明。更改导入到
as stated in the imports. Change the import to
android.support.v4.app.Fragment
和中投将获得成功。
这篇关于我的片段不能被转换为android.support.v4.app.Fragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文