Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - how to remove the view of linear layout

In my application i am adding the view dynamically to the linear layout. each view consists of one button if you click on that then view will be deleted. How to refresh the linear layout? because when i removed any view then the view's positions will be changed.

like image 817
naresh Avatar asked Jan 05 '12 10:01

naresh


People also ask

Is linear layout deprecated?

This constant is a layoutMode . This constant is a layoutMode . This constant was deprecated in API level 28.

How do I fix the bottom layout on my android?

You can set the layout_height="0dp" of your header, footer and ScrollView and define a layout_weight . Just play around with the values until you find out which works best. The resulting heights of header and footer would dynamically change with the screensize.


2 Answers

To remove any view you can use

ll.removeView(view)// to remove particular view
ll.removeViewAt(position);// to remove view from particular position

Use following logic to remove any view from layout

ll.post(new Runnable() {
    public void run() {
        ll.removeView(view);
    }
});
like image 182
Sunil Kumar Sahoo Avatar answered Sep 18 '22 14:09

Sunil Kumar Sahoo


You question is not that clear. But you could try setting the view as visibility = gone.

like image 42
Snicolas Avatar answered Sep 16 '22 14:09

Snicolas