public int result;
public int confirm(Context context,String title, String message) {
Dialog dialog = new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(message)
.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
result = 1;
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
result = 2;
}
}).create(); dialog.show();
Log.i(Constant.LOG_TAG, "click result = "+String.valueOf(result));
return result;//这里在onClick()执行之前result就返回了,如何返回onClick()里面的result的值?
}
解决方案 »
- 求助!提醒功能的实现(service,broadcast,alarmmanage)
- [Android 网络] ksoap2与webservice交互报错
- 求助用过DroidBox或TaintDroid的大神
- 求Eclipse的android开发环境
- android 1.6 怎么删除SIM卡上的联系人?求代码
- 庖丁解牛分词器的配置
- 关于手机重力传感器
- 关于android下的模拟HTTPS发送请求
- 求教关于ScrollView和相对大的文本显示问题
- android按钮不同样式的做法
- android手机设置无动画,但UC的所有动画还有效,请问这是怎么做到的
- 现在用C 开发Android,稳定可靠吗?
public void onClick(DialogInterface dialog, int which) {
result = 1;
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
result = 2;
}
}).show();
new AlertDialog....
....
...
dialog.show();
这样写一大串代码。