首页 > 移动平台 > 详细

Android showDialog时报错requestFeature() must be called before adding content

时间:2016-03-03 14:42:44      阅读:219      评论:0      收藏:0      [点我收藏+]
View view = View.inflate(this, R.layout.layout_dialog, null);
        AlertDialog alertDialog = new AlertDialog.Builder(TabActivity.this, R.style.CustomDialog).create();
        alertDialog.setContentView(view);
        alertDialog.show();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.setCancelable(true);

运行上面的代码报错:

技术分享

 

原因:

于dialog.show()之前调用了dialog.setContentView()或者dialog.getwindow()等,正确的应该是dialog.show()之后调用dialog.setContentView()

Android showDialog时报错requestFeature() must be called before adding content

原文:http://www.cnblogs.com/butterfly-clover/p/5238213.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!