Tabhost tutorial broken?

Possible duplicate:
Does anyone know what this error means for Android tabs?

I am trying to make a TabHost tutorial in the SDK, but for some reason it seems to break. In step 4, I copy and paste the xml code, I get an error message that prevents it from being overestimated. error:

Error in an XML file: aborting build. 

This is in the graphic layout of the xml file.

 Error during post inflation process: TabHost requires a TabWidget with id "android:id/tabs", View found with id "tabs" is 'com.android.layoutlib.bridge.MockView' 

The xml file has this in it.

  <?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" 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" /> </LinearLayout> </TabHost> 

Am I doing something wrong?

+4
source share
4 answers

Use this template:

 <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:id="@+id/tab" 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:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"/> <LinearLayout android:id="@+id/tab2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"/> </FrameLayout> </LinearLayout> </TabHost> 
+2
source

See step 5, your activity should extend TabActivity, not Activity

Now open HelloTabWidget.java and increase TabActivity:

+2
source

You can use the updated rendering library found here: Android tools .

Just extract the directories found in \layoutlib\[platform version] in \[sdk dir]\platforms\[platform version] and override layoutlib .

0
source

Go to the landing page of Android 3.0 or 3.1 in the graphic layout itself. You can find the dropdown in the upper right corner

0
source

Source: https://habr.com/ru/post/1334571/


All Articles