今天遇到如下错误,提示xml文件有问题,困扰了蛮久,最后解决了,记录一下。
原因:在非UI线程中执行了inflater.inflate(R.layout.toast_list, null);
解决办法:new一个handle,然后发消息在handle中去执行inflater.inflate(R.layout.toast_list, null);
11-04 16:28:06.815 2212-4035/? E/BaseJsonHttpCallable: Binary XML file line #7: Error inflating class android.widget.ListView
android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.ListViewat android.view.LayoutInflater.createView(LayoutInflater.java:606)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:586)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)