我一直在关注Google提供的Tab示例.我正在尝试使用提供的XML布局来设置选项卡布局.
我使用这个XML布局@ http://developer.android.com/guide/tutorials/views/hello-tabwidget.html
<?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">
<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">
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is a tab" />
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is another tab" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is a third tab" />
</FrameLayout>
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
当我在Eclipse布局设计器中切换Layout选项卡时,我在Eclipse中得到一个NullPointerException:null错误.
当我尝试拖放TabHost,然后将TabWidget拖放到空布局文件中时,也会发生这种情况.
我究竟做错了什么 ?这看起来很简单.
| 归档时间: |
|
| 查看次数: |
3736 次 |
| 最近记录: |