TabHost setup(LocalActiv....) Fragments

  • Antworten:0
Manuel
  • Forum-Beiträge: 12

12.12.2012, 16:45:55 via Website

Hallo Forum,

leider steige ich gerade nicht druch und erhoffe mir hilfe.
Ich bekomme folgenden Fehler:
1java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?
hier der Code dazu:

1public View onCreateView(LayoutInflater inflater, ViewGroup container,
2 Bundle savedInstanceState) {
3 myView = inflater.inflate(R.layout.details, container, false);
4 TabHost tabHost = (TabHost)myView.findViewById(R.id.tabhost);
5 tabHost.setup();
6 TabSpec photospec = tabHost.newTabSpec("Photos");
7 photospec.setIndicator("PHOTOS", getResources().getDrawable(R.drawable.ic_friends));
8 Intent photosIntent = new Intent(getActivity(), Test1.class);
9 photospec.setContent(photosIntent);
10
11 // Tab for Songs
12 TabSpec songspec = tabHost.newTabSpec("Songs");
13 photospec.setIndicator("SONGS", getResources().getDrawable(R.drawable.ic_action_search));
14 Intent songsIntent = new Intent(getActivity(), Test2.class);
15 songspec.setContent(songsIntent);
16
17 tabHost.addTab(photospec); // Adding photos tab
18 tabHost.addTab(songspec);
19 return myView;
20 }

Das ganze passiert in einem Fragment.
hier die details.xml
1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http: //schemas.android.com/apk/res/android"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 android:orientation="vertical" >
6
7 <TabHost
8 android:id="@+id/tabhost"
9 android:layout_width="match_parent"
10 android:layout_height="match_parent" >
11
12 <LinearLayout
13 android:orientation="vertical"
14 android:layout_width="fill_parent"
15 android:layout_height="fill_parent">
16 <TabWidget
17 android:id="@android:id/tabs"
18 android:layout_width="fill_parent"
19 android:layout_height="wrap_content" />
20 <FrameLayout
21 android:id="@android:id/tabcontent"
22 android:layout_width="fill_parent"
23 android:layout_height="fill_parent"/>
24 </LinearLayout>
25 </TabHost>
26</LinearLayout>

Mir ist leider überhaupt nicht klar woher ich den LocalActivityManager herbekommen soll.

Oder hat jemand evtl. einen anderen Ansatz um Tabs in ein Fragment zu bekommen.

Danke für die Hilfe
Manuel

Antworten