ListView控件的ID属性为'android.R.id.list“错误时,我有ListView控件ID设置是否正确 [英] ListView whose id attribute is 'android.R.id.list' Error when I have the ListView id set correctly
问题描述
我有一个自定义适配器列表视图。我得到的标准
I have a Listview with a custom adapter. I am getting the standard
Your content must have a ListView whose id attribute is 'android.R.id.list'
错误,但是,我的ListView有一个机器人:ID =@机器人:ID /列表
设置值。这真的做我的头,任何建议?
error, however, My ListView has an android:id="@android:id/list"
value set. It's really doing my head in. Any suggestions?
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Layout">
<ListView android:id="@android:id/list" style="@stlye/ListMenuView"></ListView>
</LinearLayout>
styles.xml
styles.xml
<resources>
<style name="Layout" parent="@android:Theme">
<item name="android:background">@drawable/background</item>
<item name="android:scaleType">fitXY</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:orientation">vertical</item>
</style>
<style name="ListMenuView">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:cacheColorHint">#00000000</item>
</style>
</resources>
我的onCreate方法:
My onCreate method:
/** Called when the activity is first created. */
@Override
public void onCreate( Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
setContentView( R.layout.main );
m_menu = new ArrayList<ListItemData>();
populateMenu();
this.m_adapter = new ListMenuAdapter( this, R.layout.list_item, m_menu );
setListAdapter(this.m_adapter);
}
任何想法?
推荐答案
机器人:ID =@机器人:ID /列表
完美的作品,我的问题是我有那继承这是继承了基类的 ListActivity 并没有的ListView 作为开机画面活动定义启动画面。我已经改变了闪屏,只是继承活动。所有工作正常。
android:id="@android:id/list"
works perfectly, My issue was I had a Splash screen that inherited a base class which was inheriting ListActivity and had no ListView defined for the splash screen activity. I have altered the SplashScreen to just inherit Activity. All works as expected.
这篇关于ListView控件的ID属性为'android.R.id.list“错误时,我有ListView控件ID设置是否正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!