开发者

Android, trying to figure out how to remove a button

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜