android:listActivity在选项卡下

android:listActivity在选项卡下,android,listview,tabs,listactivity,Android,Listview,Tabs,Listactivity,抱歉,如果这是重复,我在网上找到的解决方案都不适合我 我有两个选项卡,我正在尝试向其中一个选项卡添加列表。代码如下: public class Library extends ListActivity { ParsingDBHelper mDbHelper; ListView lv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedI

抱歉,如果这是重复,我在网上找到的解决方案都不适合我

我有两个选项卡,我正在尝试向其中一个选项卡添加列表。代码如下:

public class Library extends ListActivity {

    ParsingDBHelper mDbHelper;
    ListView lv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle extra = getIntent().getExtras();
        String temp = extra.getString(Httpdwld.RESULT);

        mDbHelper = new ParsingDBHelper(this);
        mDbHelper.open();

        parsing();

        fillData();
    }    

    private void parsing() {
        // IMPLEMENT
    }

    private void fillData() {
        Cursor c = mDbHelper.fetchAllSearch();
        String[] FROM = new String[] {ParsingDBHelper.KEY_TITLE, ParsingDBHelper.KEY_AUTHOR,
                ParsingDBHelper.KEY_YEAR, ParsingDBHelper.KEY_LOCATION, 
                ParsingDBHelper.KEY_CALL_ISBN, ParsingDBHelper.KEY_AVAILABILITY};
        int[] TO = new int[] {R.id.row_title, R.id.row_author, R.id.row_year, 
                R.id.row_location, R.id.row_id, R.id.row_avail};
        SimpleCursorAdapter notes = 
            new SimpleCursorAdapter(this, R.layout.row_layout, c, FROM, TO);
        lv.setAdapter(notes);
    }
}
mDbHelper只是使用SQLiteDatabase的助手

这是我的标签的XML代码

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
             />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >               
        </FrameLayout>
        <ListView android:id="@android:id/list"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
        />

    </LinearLayout>>
</TabHost>
}


有什么建议吗?

您的活动必须在AndroidManifest.xml中列出。您的logcat也会将此作为例外显示。

使用Eclipse中的adb logcat、DDMS或DDMS透视图查看logcat并检查与错误相关的堆栈跟踪。
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.search_result);

        TabHost tabHost = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;

        intent = new Intent(this, Library.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("Library").setIndicator("Library")
        .setContent(intent);
        tabHost.addTab(spec);