我是新來的android編程。android - ListActivity和ListView
我坐上從ListActivity
上線
setContentView(R.layout.main);
在嘗試使用Log.e()
延長我的Activity
錯誤/趕上logcat的說:
5月12日至25日:58:36.959 :E/ERROR(657):錯誤代碼:android.view.InflateException:二進制XML文件行#6:錯誤充氣類Listview
我的main.xml如下:
活動的<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Listview
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="asd"/>
</RelativeLayout>
代碼:
import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
public class StatusListActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.main);
} catch(Exception e) {
Log.e("ERROR",e.toString());
}
}
}
我想你應該重命名你的類ListActivity。但是,最好向我們提供與此佈局文件相對應的活動代碼。 – Yury 2011-12-25 00:53:19