findViewById(R.id.list)没有解析?
我收到以下错误消息: R.id.list无法解析。
我正在扩展ListActivity,在布局中我有ListView android:id =“@ android:id / list”
public class Results extends ListActivity {
static final String TAG = "Results";
ListView m_lv;
List<Map<String, String>> m_dataList = null;
ListView lv;
SimpleAdapter m_adapter;
ProgressDialog m_dialog;
AsyncTask<String, String, String> bg;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listviewparent);
lv = (ListView) findViewById(R.id.list);
lv = getListView();
下面是listviewparent.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout style="@style/TitleBar">
<ImageButton style="@style/TitleBarAction"
android:contentDescription="@string/description_home"
android:src="@drawable/title_home"
android:onClick="onClickHome" />
<ImageView style="@style/TitleBarSeparator" />
<TextView style="@style/TitleBarText" />
<ImageButton style="@style/TitleBarAction"
android:contentDescription="@string/description_about"
android:src="@drawable/title_about"
android:onClick="onClickAbout" />
<ImageButton style="@style/TitleBarAction"
android:contentDescription="@string/description_search"
android:src="@drawable/title_search"
android:onClick="onClickSearch" />
</LinearLayout>
<ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="0px"/>
</LinearLayout>
有什么想法吗?
提前致谢。
答案 0 :(得分:6)
对于R.id.list,名称空间必须为android.R
,但对于您的查看父级,您的R
是您的程序名称空间之一。只需将android.
添加到R.id.list
的开头即可修复命名空间。
答案 1 :(得分:3)
使用此:
findViewById(android.R.id.list)