AlertDialog显示错误 Unable to add window token null is not for an application

错误代码

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

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容