Ted pottel
Ted pottel

Reputation: 6993

Android, trying to figure out how to remove a button

I'm dymcally adding EditView, and would like to remove them from a LinearLayout container, the code I use to add the edit views

// month
mMonth[index] = new EditText(this);
result = cDates.GetStrMonth(index).toCharArray();
mMonth[index].setText(result,0,result.length);
layout.addView(mMonth[index])

Ted

Upvotes: 0

Views: 2133

Answers (2)

jkhouw1
jkhouw1

Reputation: 7350

if you want to remove all the children you could simply

ArrayList<View> views = layout.getTouchables();
                for(View v1: views){
                    layout.removeView(v1);
                }

if you need to be more careful about what view you remove, you will need to inspect each view v1 to determine if you want to remove it or not.

Upvotes: 1

Kevin Coppock
Kevin Coppock

Reputation: 134714

layout.removeView(mMonth[index]);

:)

Upvotes: 2

Related Questions