我在圖像上使用onClick來運行AlertDialog。 onClick在AsyncTask的onPostExecute中設置。將參數從AsyncTask傳遞給方法
ImageView image = new ImageView(getApplicationContext());
image.setBackgroundResource(R.drawable.ic_action_discard);
image.setId(n);
image.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showpopup();
}
});
當對話框被顯示,並在用戶按下肯定按鈕我需要運行與圖像的ID查詢..
我如何才能在獲得圖像的標識下課;
public void showpopup() {
new AlertDialog.Builder(this)
.setTitle(getString(R.string.Alertdialognl1))
.setMessage(getString(R.string.Alertdialognl2))
.setPositiveButton(getString(R.string.Alertdialognlja),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface Dialog,
int which) {
Log.i("positive", "clicked");
}
})
.setNegativeButton(getString(R.string.Alertdialognlnee),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface Dialog,
int which) {
Log.i("negative", "clicked");
}
}).show();
}