I'开发者_Go百科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
layout.removeView(mMonth[index]);
:)
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.
精彩评论