Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android empty Linear layout contents

H have multiple TextViews inside an LinearLayout. Now I want to delete this text view in java. The views are generated dynamically. How can I empty all contents inside this LinearLayout?

<LinearLayout android:layout_width="match_parent"         android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/myid">      <TextView .../>     <TextView .../>     <TextView .../>  </LinearLayout> 
like image 992
Manoharan Avatar asked Mar 08 '12 07:03

Manoharan


People also ask

What is layout_weight and weightSum in android?

android:weightSum. Defines the maximum weight sum. If unspecified, the sum is computed by adding the layout_weight of all of the children. This can be used for instance to give a single child 50% of the total available space by giving it a layout_weight of 0.5 and setting the weightSum to 1.0.

What is the difference between linear layout and constraint layout?

ConstraintLayout has dual power of both Relative Layout as well as Linear layout: Set relative positions of views ( like Relative layout ) and also set weights for dynamic UI (which was only possible in Linear Layout). Despite the fact that it's awesome, it fails to serve the purpose with simple UI layouts.

What is 0dp android?

Equal distribution. To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout).


1 Answers

You can use this:

LinearLayout ll = (LinearLayout) findViewById(R.id.myid); ll.removeAllViews(); 
like image 99
Ted Hopp Avatar answered Sep 20 '22 22:09

Ted Hopp