【发布时间】:2013-02-27 04:47:35
【问题描述】:
我的AlertDialog 有什么问题? Logcat 仅到达 "after builder set items",然后它停止并且没有错误消息。应用程序的其余部分继续没有问题。不知道为什么AlertDialog 不会显示。
AlertDialog.Builder builder = new AlertDialog.Builder(this.cordova.getActivity());
Log.d(LOG_TAG, "after new AlertDialog");
builder.setTitle(title);
Log.d(LOG_TAG, "after builder set title");
CharSequence[] choicesAsCharSeq = choices.toArray(new CharSequence[choices.size()]);
builder.setItems(choicesAsCharSeq, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
Log.d(LOG_TAG, "Index #" + which + " chosen.");
String result = "";
result = "" + which;
// ActionSheet.this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
}
});
Log.d(LOG_TAG, "after builder set items");
builder.show();
Log.d(LOG_TAG, "after builder show");
【问题讨论】:
-
您在标签中提到了 logcat。那么,logcat 在哪里呢?
-
可能你从 appwidget 或非 UI 线程调用对话框。
-
我想这个问题与 logcat 本身无关。
-
@AlexKucherenko 你可能是对的。这是在phonegap中。我正在使用这一行来声明我的班级:
public class ActionSheet extends Plugin { -
但如果我使用
new AlertDialog.Builder(this.cordova.getActivity()),它应该在主线程上吗?
标签: java android cordova android-alertdialog phonegap-plugins