Error : Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabs

梦想与她 提交于 2019-12-08 16:47:48
Rehan K

You're having error with xml and public void intialiseTabWidgets() method

xml should be changed as:

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout 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" >

      <TabHost
            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"
                     android:background="#160203" />

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"/>

            </LinearLayout>

        </TabHost>

</FrameLayout>

and use intialiseTabWidgets() method should have null references oncreate method

TabHost tabHost = getTabHost(); 

should be changed to

tabHost = getTabHost();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!