錯誤代碼
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倔叼。
完美解決(:зゝ∠)
解決方案是抄別人的逃片。