我正在处理选项卡,每个选项卡都显示一个列表视图
我的代码如下:(我只显示第一个选项卡的代码)任何人都可以帮助我哪里出错了吗?
我的XML文件如下
<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="fill_parent" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="60dp" >
<ListView
android:id="@+id/pcards_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
</LinearLayout>
</FrameLayout>
我的 MAIN.XML 如下
IT 没有显示任何错误,但是当我在模拟器上运行它时程序仍然崩溃
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost mtabhost =(TabHost)findViewById(R.id.tabHost);
mtabhost.setup();
TabSpec spec1 = mtabhost.newTabSpec("Tab 1");
spec1.setContent(R.id.tab1);
spec1.setIndicator("Personal Cards");
ListView pcards_list= (ListView)findViewById(R.id.pcards_list);
ArrayList<String> pcards_arraylist = new ArrayList<String>();
ArrayAdapter<String> adapter1= new ArrayAdapter<String(this,android.R.layout.simple_list_item_2,pcards_arraylist);
pcards_list.setAdapter(adapter1);
mtabhost.addTab(spec1);
}
}
请帮帮我!
任何人都可以为我提供一个很好的关于标签的教程以及使用具有列表视图的片段的标签吗?先感谢您