4
嗨guyzz我有TabActivity如下簡單的代碼java.lang.IllegalStateException ..... at tabhost.add(tabspec);
public class TabhostActivity extends Activity{
TabHost host;
public class TabhostActivity extends Activity{
TabHost host;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tablayout);
host = (TabHost) findViewById(R.id.mytabhost);
host.setup();
Intent intent = new Intent(getApplicationContext(), RatingBarActivity.class);
TabHost.TabSpec spec = host.newTabSpec("positions").setIndicator("Positions",getResources().getDrawable(R.drawable.add)).setContent(intent);
host.addTab(spec);
host.setCurrentTab(0);
}
,並有一個簡單的標籤佈局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabHost
android:id="@+id/mytabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FF0000">
</FrameLayout>
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TabWidget
android:layout_marginLeft="5dp"
android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tabStripEnabled="true" >
</TabWidget>
</HorizontalScrollView>
</LinearLayout>
</TabHost>
</LinearLayout>
所以,請幫我在哪裏代碼越來越不對?我有例外,因爲
02-23 14:09:47.920:E/AndroidRuntime(1000):java.lang.IllegalStateException:通過引起你忘了叫 '公共無效設置(LocalActivityManager的ActivityGroup)'?
感謝ü維克拉姆?它工作..我高壓浪費了2天在這個RnD ... – NullPointerException 2012-02-23 09:31:00
1更多的幫助,請我想膨脹佈局到每個選項卡..我hv完成這個視圖= LayoutInflater.from(上下文).inflate(R.layout。 tab_indicator,null,false); \t \t TextView tv =(TextView)view.findViewById(R.id.title); \t \t tv.setText(text); \t \t return view; – NullPointerException 2012-02-23 09:33:28
我的標籤是這樣的http://postimage.org/image/ts77xbmg3/1b52d397/ – NullPointerException 2012-02-23 09:41:43