我有一個列表活動,使用的佈局不僅僅是列表視圖。它也有一個按鈕和一個微調。我收到錯誤,說我需要一個名爲'list'的listview小部件。如何爲我的ListActivity定義列表?
10-15 23:28:36.131:ERROR/AndroidRuntime(448):java.lang.RuntimeException:無法啓動活動ComponentInfo {rams.rss/rams.rss.RamsRSS}:java.lang.RuntimeException:Your內容必須有一個ListView,其id屬性是'android.R.id.list'
但是,它已經有一個名爲list的listview對象。我用一個解決方案在這裏:
Why does my Android app keep telling me I need to define a ListView id when it is already defined?
它不僅造成在其中添加了.OUT後綴複製另一個錯誤。
rams_layout.xml - > rams_layout.out.xml
這裏是XML文件的內容,我使用:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button android:text="Back" android:layout_width="wrap_content" android:id="@+id/button1" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"></Button>
<Spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/button1" android:layout_alignParentRight="true"></Spinner>
<ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/spinner1" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true"></ListView>
</RelativeLayout>
關於如何解決此問題的任何想法?
可以發佈後在您活動的onCreate方法的代碼? – goto10
可以解釋你確切的錯誤嗎? –