我这门课有问题。当我按下按钮时,将调用此 Activity。当我将 Activity 扩展到此类时,程序会进入该类,但是当我扩展 ListActiviy 并单击按钮时,调试器会用红色字样告诉我“找不到源”,没有其他内容,甚至在 logcat 中也没有。请告诉我此活动的 xml 文件或清单中是否缺少某些内容。
这是课堂活动:
public class SeeAllEntriesActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all_entries);
ActivitiesObjects ao = (ActivitiesObjects)this.getApplication();
List<Customer> listOfCostumer = ao.getListOfCustomers();
ListAdapter listAdapter = new ArrayAdapter(this, R.layout.activity_all_entries, listOfCostumer);
ListView listViewCustomer = (ListView) findViewById(R.id.listViewCustomer);
listViewCustomer.setAdapter(listAdapter);
}
}
这是活动的 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="all entries" />
<ListView
android:id="@+id/listViewCustomer"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
这是清单的 xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application android:name="com.example.testapp.ActivitiesObjects" android:label="@string/app_name">
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="CreateActivity"></activity>
<activity android:name="SeeAllEntriesActivity"></activity>
</application>
</manifest>
在此先感谢,亚历克斯