解决Your content must have a ListView whose id attribute is ‘android.R.id.list

关于解决Your content must have a ListView whose id attribute is ‘android.R.id.list’的问题:
很可能是因为我们要实现对ListView中setOnItemClick的事件监听而去继承了LiseActivity,但是却没有ListView的标签,解决问题方法很简单:
ListView的id设置为“@android:id/list”或android:id=”@id/android:list”
用getListView来获取ListView的对象了。
在开发的过程中还会遇到类似的问题比如:TabHost
错误信息为:Your content must have a TabHost whose id attribute is ‘android.R.id.tabhost’
添加android:id=”@android:id/tabhost”, 这样就可以了。
还会遇到这样一个错误描述:Your TabHost must have a TabWidget whose id attribute is ‘android.R.id.tabcontent’
同样解决方法为:修改FrameLayout添加id属性
格式android:id=”@android:id/tabcontent

完整的参考一下:

<?xml version=”1.0″ encoding=”utf-8″?>
<TabHost
android:id=”@android:id/tabhostxmlns:android=”http://schemas.android.com/apk/res/androidandroid:layout_width=”fill_parent” android:layout_height=”fill_parent”>
<LinearLayout android:id=”@+id/userandroid:layout_height=”fill_parent”
android:layout_width=”fill_parent” android:orientation=”vertical”>
<TabWidget android:id=”@android:id/tabsandroid:layout_height=”wrap_content”
android:layout_width=”fill_parent”>
</TabWidget>
<FrameLayout android:id=”@android:id/tabcontentandroid:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
</FrameLayout>
</LinearLayout>
</TabHost>

注意:一个工程中只能有一个TabHost。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值