I'm sort of newbie to android arena. I built a layout for android ListView
as below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:id="@+id/homepgeaudiobtn"
android:background="#E6E7E2">
<RelativeLayout android:weightSum="1.0"
android:layout_width="fill_parent" android:layout_alignParentBottom="true"
android:background="#cf1616" android:layout_height="40dp">
<TextView android:id="@+id/textView1"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="RDMS" android:textColor="#FFF" android:textStyle="bold" android:layout_alignParentTop="true" android:layout_centerInParen开发者_如何学运维t="true" android:layout_margin="2dp" android:textSize="28dp"></TextView>
<Button android:textColor="#FFF" android:layout_height="30dp"
android:layout_margin="5dp" android:layout_width="90dp"
android:layout_alignParentLeft="true" android:background="@drawable/back_button"
android:text="@string/gobackString" android:id="@+id/buttonBack" android:layout_alignParentBottom="true"></Button>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_centerVertical="true" android:layout_alignParentRight="true" android:layout_marginRight="27dp" android:text="1/1" android:textColor="#FFF" android:id="@+id/textViewCount" android:textSize="20dp"></TextView>
</RelativeLayout>
<RelativeLayout android:id="@+id/layout02"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_marginBottom="60dp" android:layout_height="fill_parent"/>
<LinearLayout android:weightSum="1.0"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:id="@+id/layoutfooterbutton">
<Button android:layout_weight=".30" android:layout_margin="2dp"
android:id="@+id/ButtonCamera"
android:layout_height="60dp" android:layout_width="100dp"
android:textColor="#FFF" android:gravity="bottom|center"
android:textSize="12dp" android:background="@drawable/redcam" />
<Button android:layout_weight=".30" android:layout_height="60dp" android:layout_width="100dp"
android:gravity="bottom|center" android:background="@drawable/redblank"
android:textColor="#E6E7E2" android:id="@+id/ButtonBrowse" android:layout_marginTop="2dp"/>
<Button android:layout_weight=".30" android:layout_margin="2dp"
android:layout_height="60dp" android:layout_width="100dp"
android:textColor="#FFF" android:gravity="bottom|center"
android:textSize="12dp" android:background="@drawable/reddelete" android:id="@+id/ButtonDelete"/>
</LinearLayout>
<TextView android:layout_height="0dp"
android:layout_alignParentBottom="true" android:layout_width="0dp"
android:background="#000" android:text="@string/footer"
android:gravity="center"></TextView>
</RelativeLayout>
</LinearLayout>
then I wrote the following code in onCreate()
method
setContentView(R.layout.video_listview);
ListView lv = (ListView)findViewById(R.id.list);
setListAdapter(new MyThumbnaildapter(AndroidThumbnailList.this,R.layout.row_thumb,db_results));
When I run the program I get the error message as -
08-05 11:00:41.265: ERROR/AndroidRuntime(32523): java.lang.RuntimeException: Unable to start activity ComponentInfo{a.b/a.b.AndroidThumbnailList}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
can anybody tell me what is the issue?
if you are using a ListActivity you must set the id of the ListView to : android:id="@android:id/list"
if you are using extents ListActivity then you hv to use
and if u r using extends Activity
<ListView android:id="@+id/listView"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
精彩评论