java.lang.Object tag = v.getTag();
if (tag instanceof java.lang.String) {
java.lang.String waybillNum = (java.lang.String) tag;
android.support.v7.app.AlertDialog alertDialog = new AlertDialog.Builder(this)
.setMessage("你確定要刪除" + waybillNum + "本地緩存數據嗎?")
.setNegativeButton("取消", null)
.setTitle("溫馨提示")
.setPositiveButton("確定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (dialog instanceof AlertDialog) {
AlertDialog alertDialog = (AlertDialog) dialog;
Button button = alertDialog.<Button>findViewById(android.R.id.button1);
if (button != null) {
Object tag = button.getTag();
if (tag instanceof String) {
String waybillNum = (String) tag;
Log.d("debug", "打印tag->" + waybillNum);
int deleteResultForWaybillDO = deleteWaybillDoByWaybillNum(waybillNum);
int deleteResultForWaybillSubDO = deleteWaybillSubDoByWaybillNum(waybillNum);
if (deleteResultForWaybillDO > 0 && deleteResultForWaybillSubDO > 0) {
Toast.makeText(AccordingToDriverDeliveryScanActivity.this, "刪除成功", Toast.LENGTH_LONG).show();
refreshInterfaceDisplayData(null);
}
}
}
}
}
})
.create();
alertDialog.show();
android.widget.Button button = alertDialog.<android.widget.Button>findViewById(android.R.id.button1);
if (button != null) {
button.setTag(waybillNum);
}
}
Android通过AlertDialog传递局部参数
该代码段展示了一个在Android中使用Java编写的确认对话框,用于询问用户是否确定删除特定的本地缓存数据(waybillNum)。如果用户点击“确定”,则会调用删除方法并更新界面显示。
82

被折叠的 条评论
为什么被折叠?



