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

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

你可能感兴趣的:(AlertDialog显示错误 Unable to add window token null is not for an application)