0

我有一些代码可以构建一个对话框并为其创建一个侦听器。对话框显示正常,但侦听器内部的代码似乎没有运行,我不知道为什么。

private void showBackgrounDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(MeacruxActivity.this);
        builder.setTitle(R.string.background_dialog_title).setCancelable(true)
                .setItems(R.array.background_options, 
                        new DialogInterface.OnClickListener(){
                            @Override
                            public void onClick(DialogInterface dialog, int selection) {
                                Log.d(logID, "the selection is: " + selection);
                                if(backgrounds.length==selection){
                                    notImplementedYet.show();
                                return;
                            }
                            setBckground(backgrounds[selection]);   
                        }
                    });

    currentDialog = builder.create();
    currentDialog.show();
}

private void setBackground(String bgName) {
        Log.d(logID, bgName);
}

该对话框正确显示了所有选项和所有内容,但是当我单击一个时,日志中没有任何内容....这是为什么?

编辑:我做了更多测试,我可以确认onClick函数内部的代码正在运行,只是日志没有显示......

4

1 回答 1

0

I'm assuming you are looking in eclipse or studio In DDMS view, make sure the device is selected. In Logcat view, make sure there's not a filter applied.

On terminal, type adb logcat... does it show up there?

于 2013-07-20T00:32:19.433 回答