【发布时间】:2011-02-04 07:42:59
【问题描述】:
我正在关注本教程https://developer.android.com/guide/tutorials/views/hello-tabwidget.html 并已完成。现在我实际上想在这些选项卡中添加一些控件,例如文本框(文本编辑)。
我该怎么做?我使用 eclipse 作为我的 ide 转到我的 mail.xml 并转到布局视图,现在我得到一个 NullPointerException,所以我什至不能再将东西拖到布局上。
编辑
这就是我所拥有的
<?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">
<LinearLayout
android:orientation="vertical"
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" />
<EditText android:text="" android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:password="true"></EditText>
</LinearLayout>
<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>
【问题讨论】:
-
@chobo2:你看过我给出的答案了吗?我认为我对这个问题进行了相当彻底的审查。
-
@Steve : 抱歉一直在写期末考试,我现在正在看。
-
仅供参考,
HelloTabWidget使用已弃用的 UI 组件,并已从 Android 开发者网站中删除。