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

相关文章:

  • 2021-10-26
  • 2021-07-18
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2021-06-13
猜你喜欢
  • 2021-06-16
  • 2021-10-18
  • 2022-01-02
  • 2021-10-31
  • 2021-04-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案