我正在尝试更改选项卡视图的活动,并且正在尝试访问标题为“选项卡内容”的框架布局。
我不断收到错误:
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);
我不知道为什么会这样......我会很感激任何帮助!