H 在一个 LinearLayout
中有多个 TextViews
。现在我想在java中删除这个 TextView 。 View 是动态生成的。如何清空此 LinearLayout
中的所有内容?
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/myid">
<TextView .../>
<TextView .../>
<TextView .../>
</LinearLayout>
最佳答案
你可以用这个:
LinearLayout ll = (LinearLayout) findViewById(R.id.myid);
ll.removeAllViews();
关于Android 空线性布局内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9614240/