美文网首页
AlertDialog显示错误 Unable to add wi

AlertDialog显示错误 Unable to add wi

作者: 敌军不是十五万 | 来源:发表于2016-09-21 17:51 被阅读58次

错误代码

AlertDialog imageDialog = new AlertDialog.Builder(context).create();  
imageDialog.show();

以下为AlertDialog创建语句。

public AlertDialog.Builder (Context context)

所以在创建AlertDialog时,不能使用getApplicationContext()得到的context,而必须使用Activity。即Activity.this
adapter
中使用时,用View.getContext()即可得到所需context

完美解决(:зゝ∠)
解决方案是抄别人的。

相关文章

网友评论

      本文标题:AlertDialog显示错误 Unable to add wi

      本文链接:https://www.haomeiwen.com/subject/ummaettx.html