单击列表项时,我需要调用带有2个选项卡的界面。这两个标签应包含2个单独的活动。
我设计使用扩展Tab活动的类来调用每个选项卡,并为每个选项卡分隔活动类。我遇到的问题是,我需要从列表中调用tab活动类。我该怎么办?
这是我的代码:
public void onItemClick(AdapterView<?> parent, View view, int position,long id3)
{
Intent myIntent = new Intent(getApplicationContext(), InfoActivity.class);
startActivity(myIntent);
}
这是日志:
02-11 15:50:21.978: E/AndroidRuntime(745): at dalvik.system.NativeStart.main(Native Method)
02-11 15:50:21.978: E/AndroidRuntime(745): Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
02-11 15:50:21.978: E/AndroidRuntime(745): at android.app.TabActivity.onContentChanged(TabActivity.java:105)
02-11 15:50:21.978: E/AndroidRuntime(745): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:210)
02-11 15:50:21.978: E/AndroidRuntime(745): at android.app.Activity.setContentView(Activity.java:1657)
02-11 15:50:21.978: E/AndroidRuntime(745): at sam.todo.OnTime.InfoActivity.onCreate(InfoActivity.java:22)
02-11 15:50:21.978: E/AndroidRuntime(745): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-11 15:50:21.978: E/AndroidRuntime(745): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
info.xml代码
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/tabhost">
<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="45dp" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtViewSelectedTask"
android:layout_width="match_parent"
android:layout_height="46dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/txtInfo"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_weight="1.84"
android:gravity="top|left"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
<Button
android:id="@+id/btnSave2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/save" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>