简体   繁体   中英

List View and ListActivity question in Android

I am trying to use List View and List activity. My code is very simple, here are my java and xml files. The MyRecords.java file is:

public class MyRecords extends ListActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myrecords);
               .
               .
               .

myrecords.xml file is:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:id="@+id/myrecords">
</TextView>

and I have added this to the Manifest file:

    <activity android:name=".MyRecords"
        android:label="@string/myrecords_title" >
    </activity>

in my main activity page I have a button corresponding to MyRecords. The problem is that as soon as I press the button the application force closes. I appreciate any help in letting me know what is wrong with this code. I must mention that when instead of ListActivity, I had activity, there was no problem with the code.

Thanks for the help.

TJ1

需要为ListActivity提供一个包含具有正确id的ListView的布局(我认为它是android:id / list)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM