首页 > 代码库 > fragment报错

fragment报错

1.

java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader

 

 

I just solved this problem in Android API 8 machine (Samsung Galaxy S).

Please change Activity class to FragmentActivity.

  1. public class FragmentLayout extends Activity {} --> public class FragmentLayout extends FragmentActivity {}

  2. public static class DetailsActivity extends Activity {} --> public static class DetailsActivity extends FragmentActivity {}

  3. finally getFragmentManager() --> getSupportFragmentManager()

  4. register android-support-v4.jar to Eclipse‘s referenced Libraries

  5. put android-support-v4.jar to {root directory of your project}/libs directory

  6. change to API 10 enum (ex:simple_list_item_1) from simple_list_item_activated_1

  7. import android.support.v4.app.Fragment;

2.

Fragment异常:Binary XML file line #8: Error inflating class fragment

最近因为要做平板的app项目,所以做了个Fragment的Demo,碰到了个小Bug相信很多朋友也会遇到这个问题,现做个记录,以便节省大家的时间:

错误信息:

android.view.InflateException: Binary XML file line #8: Error inflating class fragment

 

下面我总结下此错误出现的原因:

1.XML文件中引入的Fragment路径不对(如下图)

 

 

2.在Activity继承Fragment时引入的包名不对

关于什么时候引入android.app.Fragment和android.support.v4.app.Fragment

请参考我的另外一篇文章:

点击了解:【android fragment android.support.v4.app.Fragment与android.app.Fragment区别】


 

 

3.Android中java.lang.ClassNotFoundException: ***.**** in loader dalvik.system.PathClassL

出现Caused by: java.lang.ClassNotFoundException: com.test.handler.BultiThreadHandler in loader dalvik.system.PathClassLoader[/data/app/com.test.handler-1.apk] 错误的时候,其实只是在Manifest文件中注册的Activity的名称写错了,注意!!!——Activity中的名称要写com.test.handler.BultiThreadHandler

前面要加上包名称!!! 注意拼写错误

 

cankao :http://blog.csdn.net/zhangyadick18/article/details/7329353

http://blog.csdn.net/duguang77/article/details/17579847

http://blog.sina.com.cn/s/blog_5ffd08d6010122ep.html

fragment报错