ListViewとTabHostを含むアクティビティがあります。このTabHost内で、別のアクティビティを追加しようとしていますが、クラッシュし続けます。これを引き起こしているものは何ですか?
public class MainActivity extends RoboFragmentActivity {
@InjectView(R.id.listView)
private ListView listView;
@InjectView(R.id.tabHost)
private TabHost tabHost;
@Inject
IIntentProxy intentProxy;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
tabHost.setup();
TabHost.TabSpec spec = tabHost.newTabSpec("tag");
spec.setContent(intentProxy.getIntent(DetailActivity.class));
spec.setIndicator("Title");
// It crashes on line below
// tabHost is not null, neither is spec
tabHost.addTab(spec);
}
}
。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="100" >
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabHost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="50" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
<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"
android:padding="5dp" >
</FrameLayout>
</TabWidget>
</LinearLayout>
</TabHost>
<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="50" >
</ListView>
</LinearLayout>
tabhostに追加される詳細アクティビティxmlファイルには何も含まれず、LinearLayoutのみが含まれます
public class DetailActivity extends RoboActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_activity);
}
}
スタックトレース
12-24 18:06:03.535: E/AndroidRuntime(27143): FATAL EXCEPTION: main
12-24 18:06:03.535: E/AndroidRuntime(27143): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.app/com.company.app.pages.MainActivity}: java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.os.Handler.dispatchMessage(Handler.java:99)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.os.Looper.loop(Looper.java:137)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-24 18:06:03.535: E/AndroidRuntime(27143): at java.lang.reflect.Method.invokeNative(Native Method)
12-24 18:06:03.535: E/AndroidRuntime(27143): at java.lang.reflect.Method.invoke(Method.java:511)
12-24 18:06:03.535: E/AndroidRuntime(27143): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-24 18:06:03.535: E/AndroidRuntime(27143): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-24 18:06:03.535: E/AndroidRuntime(27143): at dalvik.system.NativeStart.main(Native Method)
12-24 18:06:03.535: E/AndroidRuntime(27143): Caused by: java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:747)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.widget.TabHost.setCurrentTab(TabHost.java:413)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.widget.TabHost.addTab(TabHost.java:240)
12-24 18:06:03.535: E/AndroidRuntime(27143): at com.pages.ChargeSheetActivity.onCreate(ChargeSheetActivity.java:33)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.Activity.performCreate(Activity.java:5104)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-24 18:06:03.535: E/AndroidRuntime(27143): at android.app.ActivityThread.performLaunchActivity(ActivityThr
ead.java:2144)12-24 18:06:03.535:E / AndroidRuntime(27143):...11詳細