Android ListView 中的奇怪异常
我收到异常,但无法准确了解异常发生的位置。 我进行了搜索,但无法在堆栈跟踪中获取我的项目名称。
下面是我的堆栈跟踪
02-13 15:48:23.741: W/dalvikvm(416): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-13 15:48:24.026: W/System.err(416): android.content.res.Resources$NotFoundException: File from xml type layout resource ID #0x102000a
02-13 15:48:24.036: W/System.err(416): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1916)
02-13 15:48:24.036: W/System.err(416): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1871)
02-13 15:48:24.036: W/System.err(416): at android.content.res.Resources.getLayout(Resources.java:731)
02-13 15:48:24.036: W/System.err(416): at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
02-13 15:48:24.036: W/System.err(416): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
02-13 15:48:24.036: W/System.err(416): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
02-13 15:48:24.036: W/System.err(416): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.makeAndAddView(ListView.java:1727)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.fillDown(ListView.java:652)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.fillFromTop(ListView.java:709)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.layoutChildren(ListView.java:1580)
02-13 15:48:24.046: W/System.err(416): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
02-13 15:48:24.046: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.046: W/System.err(416): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-13 15:48:24.046: W/System.err(416): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-13 15:48:24.046: W/System.err(416): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-13 15:48:24.046: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.046: W/System.err(416): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
02-13 15:48:24.056: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1238)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.onLayout(LinearLayout.java:1044)
02-13 15:48:24.056: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.056: W/System.err(416): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-13 15:48:24.056: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-13 15:48:24.066: W/System.err(416): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-13 15:48:24.066: W/System.err(416): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-13 15:48:24.066: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.076: W/System.err(416): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-13 15:48:24.076: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.076: W/System.err(416): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
02-13 15:48:24.076: W/System.err(416): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
02-13 15:48:24.076: W/System.err(416): at android.os.Handler.dispatchMessage(Handler.java:99)
02-13 15:48:24.076: W/System.err(416): at android.os.Looper.loop(Looper.java:123)
02-13 15:48:24.076: W/System.err(416): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-13 15:48:24.076: W/System.err(416): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 15:48:24.086: W/System.err(416): at java.lang.reflect.Method.invoke(Method.java:521)
02-13 15:48:24.086: W/System.err(416): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-13 15:48:24.086: W/System.err(416): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-13 15:48:24.086: W/System.err(416): at dalvik.system.NativeStart.main(Native Method)
02-13 15:48:24.086: W/System.err(416): Caused by: java.io.FileNotFoundException:
02-13 15:48:24.086: W/System.err(416): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
02-13 15:48:24.086: W/System.err(416): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:485)
02-13 15:48:24.086: W/System.err(416): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1898)
02-13 15:48:24.086: W/System.err(416): ... 40 more
我的项目包名称是
com.stylingandroid.IntelligentLayout.SecondaryLayout;
我根本看不到我的包名称 在我遇到异常之前,我将其正确设置,异常是
02-13 15:39:25.756: W/System.err(379): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
我将 ListView Id 更改为 android:id="@id/android:list"
并在 java 代码中将适配器更改为
setListAdapter(new ArrayAdapter<String>(this,android.R.id.list, STATE));
getListView().setTextFilterEnabled(true);
My class extends ListActivity
public class StateList extends ListActivity{
期待您的回复。 谢谢。
I am getting an exception but could not get where exactly the exception occured.
I searched but could not get the my project name in the stacktrace.
Below is my stacktrace
02-13 15:48:23.741: W/dalvikvm(416): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-13 15:48:24.026: W/System.err(416): android.content.res.Resources$NotFoundException: File from xml type layout resource ID #0x102000a
02-13 15:48:24.036: W/System.err(416): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1916)
02-13 15:48:24.036: W/System.err(416): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1871)
02-13 15:48:24.036: W/System.err(416): at android.content.res.Resources.getLayout(Resources.java:731)
02-13 15:48:24.036: W/System.err(416): at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
02-13 15:48:24.036: W/System.err(416): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
02-13 15:48:24.036: W/System.err(416): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
02-13 15:48:24.036: W/System.err(416): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.makeAndAddView(ListView.java:1727)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.fillDown(ListView.java:652)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.fillFromTop(ListView.java:709)
02-13 15:48:24.046: W/System.err(416): at android.widget.ListView.layoutChildren(ListView.java:1580)
02-13 15:48:24.046: W/System.err(416): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
02-13 15:48:24.046: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.046: W/System.err(416): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-13 15:48:24.046: W/System.err(416): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-13 15:48:24.046: W/System.err(416): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-13 15:48:24.046: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.046: W/System.err(416): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
02-13 15:48:24.056: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1238)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.onLayout(LinearLayout.java:1044)
02-13 15:48:24.056: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.056: W/System.err(416): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-13 15:48:24.056: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.056: W/System.err(416): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-13 15:48:24.066: W/System.err(416): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-13 15:48:24.066: W/System.err(416): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-13 15:48:24.066: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.076: W/System.err(416): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-13 15:48:24.076: W/System.err(416): at android.view.View.layout(View.java:7035)
02-13 15:48:24.076: W/System.err(416): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
02-13 15:48:24.076: W/System.err(416): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
02-13 15:48:24.076: W/System.err(416): at android.os.Handler.dispatchMessage(Handler.java:99)
02-13 15:48:24.076: W/System.err(416): at android.os.Looper.loop(Looper.java:123)
02-13 15:48:24.076: W/System.err(416): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-13 15:48:24.076: W/System.err(416): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 15:48:24.086: W/System.err(416): at java.lang.reflect.Method.invoke(Method.java:521)
02-13 15:48:24.086: W/System.err(416): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-13 15:48:24.086: W/System.err(416): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-13 15:48:24.086: W/System.err(416): at dalvik.system.NativeStart.main(Native Method)
02-13 15:48:24.086: W/System.err(416): Caused by: java.io.FileNotFoundException:
02-13 15:48:24.086: W/System.err(416): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
02-13 15:48:24.086: W/System.err(416): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:485)
02-13 15:48:24.086: W/System.err(416): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1898)
02-13 15:48:24.086: W/System.err(416): ... 40 more
My project package name is
com.stylingandroid.IntelligentLayout.SecondaryLayout;
I could not see my package name at all
Before I had an exception which I set it right the exception was
02-13 15:39:25.756: W/System.err(379): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
I changed my ListView Id to android:id="@id/android:list"
and in java code I changed the adapter as
setListAdapter(new ArrayAdapter<String>(this,android.R.id.list, STATE));
getListView().setTextFilterEnabled(true);
My class extends ListActivity
public class StateList extends ListActivity{
Looking forward to your reply.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
似乎缺少资源 0x102000a。您需要从 R.java 反向引用该值并找到导致此问题的资源。
我还怀疑您使用了自己的 id,而不是 android.R.id.list 来标识布局 xml 文件中的资源。
请参阅 @+id/android:list 和@+id/list
ListView 并不像其他小部件那样直接。需要进行一些更详细的研究才能使其发挥作用。我经历了这个循环:)。
Seems like a resource is missing 0x102000a. You need to reverse reference this value from your R.java and find the resource that is causing this issue.
I also suspect that you have used a id of your own, and not android.R.id.list to identify your resource in your layout xml file.
Refer to What is difference between @+id/android:list and @+id/list
ListView is not as straight forward as other widgets. Takes a bit of more detailed study to get it working. I went through that cycle :).
请在 Android 开发者论坛中查看 ListView 规范:
http://developer.android.com/resources/tutorials/views/hello -listview.html
下面的方法需要一个布局资源,用于显示列表视图中的每个项目。
list_item.xml
因此,这里每个列表项都将显示为 TextView。
Please check the ListView specs in Android developer forum:
http://developer.android.com/resources/tutorials/views/hello-listview.html
The below method needs a layout resource which is used to display each item in the listview.
list_item.xml
So, here every list item will be shown as a TextView.
我也有同样的问题。我的类正在扩展
ListActivity
,我更改为Activity
并且现在正在运行。I had the same problem. My class was extending
ListActivity
, I change toActivity
and now is running.