0
我試圖改變一個tabview的活動,我試圖訪問標題爲'tabcontent'的framelayout。Android FrameLayout'tabcontent'在活動中不可用?
我不斷收到錯誤:
tabcontent cannot be resolved or is not a field.
即使它存在於我的.xml:
<?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" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" >
</TabWidget>
</LinearLayout>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="50dip"
android:layout_marginRight="50dip"
android:background="@drawable/attendance" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="50dip"
android:layout_marginLeft="50dip"
android:background="@drawable/sched" />
</FrameLayout>
</TabHost>
我在這裏稱之爲:
//on Create
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
setTabs() ;
//Sets the visibility of the attendance and schedule buttons to invisible
Button attend = (Button)findViewById(R.id.button1);
Button sched = (Button)findViewById(R.id.button2);
attend.setVisibility(View.INVISIBLE);
sched.setVisibility(View.INVISIBLE);
contentviewlayout = (FrameLayout)findViewById(R.id.tabcontent); <--ERROR
contentviewparams = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
我不不知道爲什麼會發生這種情況...我會很感激任何幫助!
'android.R.id.tabcontent'。請不要在Android中添加問題標題的前綴,底部的標籤就足夠了。 – Luksprog 2013-04-23 18:42:07