java - Android TabHost strange error -
since tabhost not deprecated, , need simple solution switch between 2 controls (maybe 3) decided tabhost perfect needs. mysterious error....
this code have
mytabhost = (tabhost) findviewbyid(android.r.id.tabhost); mytabhost.setup(); tabhost.tabspec tmpspec = null; tabcontentfactory tmpcontentfactory = null; tmpspec = mytabhost.newtabspec("main_param_time"); tmpspec.setindicator("sometext"); // error happens here here tmpspec.setcontent(r.id.charts_stickchart); // rest of code here. e.g. addtab etc.
the error
java.lang.runtimeexception: not create tab content because not find view id 2131427359
my xml file looks this:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <tabhost android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/tabhost" > <linearlayout android:id="@+id/linearlayout01" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"> <tabwidget android:id="@android:id/tabs" android:layout_height="wrap_content" android:layout_width="fill_parent"> </tabwidget> <framelayout android:id="@android:id/tabcontent" android:layout_height="fill_parent" android:layout_width="fill_parent" > </framelayout> </linearlayout> </tabhost> <cn.limc.androidcharts.view.stickchart android:id="@+id/charts_stickchart" android:layout_height="match_parent" android:layout_width="match_parent" android:visibility="gone" /> <cn.limc.androidcharts.view.spiderwebchart android:id="@+id/charts_spiderwebchart" android:layout_height="match_parent" android:layout_width="match_parent" android:visibility="gone" /> </linearlayout>
move 2 charts children of <framelayout>
, in this sample app:
<?xml version="1.0" encoding="utf-8"?> <tabhost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <tabwidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> <framelayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent"> <analogclock android:id="@+id/tab1" android:layout_width="match_parent" android:layout_height="match_parent" /> <button android:id="@+id/tab2" android:layout_width="match_parent" android:layout_height="match_parent" android:text="a semi-random button" /> </framelayout> </linearlayout> </tabhost>
Comments
Post a Comment