我有一个线性布局内的文字。现在我想删除在java中这个文本视图。该文本视图是动态生成的。我有线性布局的ID。如何清空这个线性布局中的全部内容?
< LinearLayout中的android:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT机器人:方向=垂直机器人:ID =@ + ID /身份识别码>
< TextView的... />
< TextView的... />
< TextView的... />
< / LinearLayout中>
解决方案
您可以使用此:
的LinearLayout LL =(的LinearLayout)findViewById(R.id.myid);
ll.removeAllViews();
i have a Text view inside an linear layout. now i want to delete this text view in java. this text view is generated dynamically. I have linear layout's id. how to empty all contents inside this linear layout?
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/myid">
<TextView .../>
<TextView .../>
<TextView .../>
</LinearLayout>
解决方案
You can use this:
LinearLayout ll = (LinearLayout) findViewById(R.id.myid);
ll.removeAllViews();