Problem: Recently in The Imitation Chat interface, when using Fragmenttabhost, there is No tab content framelayout found for ID 2131492944 error
Here is the XML and main_activity
Package Com.example.scott.myweixin;import Android.os.bundle;import Android.support.v4.app.fragmentactivity;import Android.support.v4.app.fragmenttabhost;import Android.widget.tabhost.tabspec;public class MainActivity extends fragmentactivity{ private fragmenttabhost tabhost; Private final static String tag_chat= "CHAT"; @Override protected void onCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main); Tabhost = (fragmenttabhost) Findviewbyid (Android. R.id.tabhost); Tabhost.setup (this, Getsupportfragmentmanager (), r.id.activity_home_container); Tabspec Spec=tabhost.newtabspec (tag_chat); Spec.setindicator ("message"); Tabhost.addtab (Spec,myfragment.class,null); }}
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "Http://schemas.andro Id.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent " android:orientation= "vertical" > <framelayout android:id= "@+id/activity_home_container" Android : layout_width= "fill_parent" android:layout_height= "0DP" android:layout_weight= "1" > </FRAMELAYOUT&G T <android.support.v4.app.fragmenttabhost android:id= "@android: Id/tabhost" android:layout_width= "Match_pare NT "android:layout_height=" Wrap_content "> <tabwidget android:id=" @android: Id/tabs " Android:layout_width= "Match_parent" android:layout_height= "Wrap_content" Android:layout_alignpar Entbottom= "true" android:background= "#FFF1F1F1" > </TabWidget> <framelayout Android:id= "@andRoid:id/tabcontent "android:layout_width=" 0DP "android:layout_height=" 0DP "> </framelay Out> </android.support.v4.app.FragmentTabHost></LinearLayout>
Also looked up some information, found that the guarantee is wrong when the mrealtabcontent is empty, but the above content is not empty
private void Ensurecontent () { if (mrealtabcontent = = null) { mrealtabcontent = (framelayout) Findviewbyid ( Mcontainerid); if (mrealtabcontent = = null) { throw new IllegalStateException ( "No tab content framelayout found for id" + Mcont Ainerid); } }
Finally, the answer on the Internet is to delete the tabwidget in the XML and it can be run. But I don't understand why. If a great God sees it, ask for answers.
No tab Content framelayout found for ID xxx