addcontentView之后如何让这个view消失掉

Dia dialog ;
public void go(View view){
dialog = (Dia) getLayoutInflater().inflate(R.layout.main, null);
LayoutParams param = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
Button btn = (Button) dialog.findViewById(R.id.btn);
btn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
((ViewGroup)dialog.getParent()).removeView(dialog);
}
});
addContentView(dialog, param);
}

需要强转成为ViewGroup,然后remove即可。

上一篇:fastJson解析报错:com.alibaba.fastjson.JSONException: can't create non-static inner class instance.


下一篇:HDU1049