錯誤代碼
AlertDialog imageDialog = new AlertDialog.Builder(context).create();
imageDialog.show();
以下為AlertDialog創(chuàng)建語句。
public AlertDialog.Builder (Context context)
所以在創(chuàng)建AlertDialog時,不能使用getApplicationContext()得到的context,而必須使用Activity。即Activity.this。
在adapter中使用時,用View.getContext()即可得到所需context。
完美解決(:зゝ∠)
解決方案是抄別人的。