想做一个tabhost分两页的界面。在每一页tab page中,放一个ListActivity.要求tab标签在界面的最下端。
tabmain.xml文件内容<?xml version="1.0" encoding="utf-8"?>  
<TabHost android:id="@+id/maintabhost"   
      android:layout_width="fill_parent"   
      android:layout_height="fill_parent"   
      xmlns:android="http://schemas.android.com/apk/res/android">  
           <RelativeLayout  
          android:id="@+id/relativeLayout1"   
          android:layout_height="match_parent"   
          android:layout_width="wrap_content"  
          android:orientation="vertical">  
            
            <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@android:id/tabcontent">  
                <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/tab1"></LinearLayout>  
                <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/tab2"></LinearLayout>   
            </FrameLayout>  
            <TabWidget android:layout_width="fill_parent"   
              android:layout_height="wrap_content"   
              android:id="@android:id/tabs"
              android:layout_alignParentBottom="true"></TabWidget>  
        </RelativeLayout>  
</TabHost>  
    
tabmini.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="40dp"  
    android:paddingLeft="5dip"  
    android:paddingRight="5dip"  
    android:background="@drawable/icon">    
      
    <TextView android:id="@+id/tab_label"    
        android:layout_width="fill_parent"  
        android:layout_height="wrap_content"  
        android:layout_centerInParent="true"  
        android:gravity="center"  
        android:textColor="#000000"  
        android:textStyle="bold"  
        android:background="@drawable/icon"/>   
</RelativeLayout>  Test1Activity.java文件名
package com.test.t1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
public class Test1 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.tabmain); TabHost tabHost = (TabHost) findViewById(R.id.maintabhost);
tabHost.setup(); //tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("p1").setContent(R.id.tab1));
//tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("p2").setContent(R.id.tab2)); Intent intent1 = new Intent(this, ListV.class);
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("p1").setContent(intent1));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("p2").setContent(intent1));
}
}ListV.java文件内容(使用了ListActivity)
package com.test.t1;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;public class ListV  extends ListActivity { @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getListView().setCacheColorHint(0);
this.getListView().setBackgroundColor(android.graphics.Color.WHITE);
SimpleAdapter adapter = new SimpleAdapter(this,getData(),R.layout.main,new String[]{"title","info"}, new int[]{1,2});
setListAdapter(adapter);
} private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>();
map = new HashMap<String, Object>();
map.put("title", "L1");
map.put("info", "1111111111111111111111111111");

list.add(map); map = new HashMap<String, Object>();
map.put("title", "L2");
map.put("info", "22222222");

list.add(map); return list;
}
}从上面的Test1Actitity.java中//tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("p1").setContent(R.id.tab1)); //tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("p2").setContent(R.id.tab2));
Intent intent1 = new Intent(this, ListV.class); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("p1").setContent(intent1)); tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("p2").setContent(intent1));使用R.id.tab1这个ListView组件来,是可以正常显示的。
但使用intent1(是一个ListActivity)则会报错。哪位能告诉一下,应该怎么弄? tabhost