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即可。

posted on   行殇  阅读(793)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示