在我的XML我在第一个3视图
In my xml i have 3 view at first
我要隐藏一个观点那之后我要取消隐藏程序。
i have to hide one view then after that i have to unhide that in program.
当我隐藏视图中的其他必须调整,当我取消隐藏它有调整
When i hide that view the other must adjust and when i unhide it have to adjust
假设你有一个这样的布局
Suppose you have a layout like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/linearLayout"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<!-- your content here -->
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<!-- your content here -->
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout03"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<!-- your content here -->
</LinearLayout>
</LinearLayout>
在你的程序中使用的起始
At the starting of your program use
LinearLayout linearLayout1,linearLayout2,linearLayout3;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
//define and declare the layouts
linearLayout1=(LinearLayout) findViewById(R.id.LinearLayout01);
linearLayout2=(LinearLayout) findViewById(R.id.LinearLayout02);
linearLayout3=(LinearLayout) findViewById(R.id.LinearLayout03);
}
现在,当你要隐藏的第一个布局,用
Now when you want to hide the first layout ,use
linearLayout1.setVisibility(View.GONE);
现在,当你想要显示的第一个布局,用
Now when you want to show the first layout ,use
linearLayout1.setVisibility(View.VISIBLE);
的情况同样为所有布局。
The situation is same for all layouts..
希望这会帮助你。