[英]Destroy layout after using setContentView
在一個按鈕上,我這樣調用布局:
setContentView(R.layout.my_form);
另一方面,我想破壞這種布局。 我該怎么做 ?
你可以使用rootView.removeAllViews();
例如,從布局中刪除所有視圖
您的布局是
<LinearLayout
android:id="@+id/llRootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
.......
</LinearLayout>
然后,您可以調用llRootView.removeAllViews();
從此線性布局中刪除所有視圖
編輯
要從布局中臨時刪除視圖,您可以使用
llRootView.setVisibility(View.GONE);
要使其再次可見,請使用
llRootView.setVisibility(View.VISIBLE);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.