1

我刚刚按照 android 网站的建议定义了一个对话框,但它没有在按钮单击时显示,一些代码 scracht(我没有错误): static final int DIALOG_A = 1; 静态最终 int DIALOG_B = 2; 文本视图文本X;

protected Dialog onCreateDialog(int id, String text) {
    Dialog dialog = new Dialog(this);
    dialog.setContentView(decrytedText);
    Log.v("DialogTest", "  onCreateDialog(): +++ START +++");

    switch(id) 
    {
        case DIALOG_A:
            dialog.setTitle(this.getString(R.string.dialog_title_wrong_key));
            break;
        case DIALOG_B:
            dialog.setTitle(this.getString(R.string.dialog_title_ok_key));
            break;
    }
    return dialog;
}

 somebutton.setOnClickListener(new View.OnClickListener() 
            {
                public void onClick(View v) 
                {
                    Object butts[] = (Object []) v.getTag();

                    try 
                    {
                        Log.v("DialogTest", " try");
                        String decrypted ="OK GO";
                        textX.setText(decrypted);
                        showDialog(DIALOG_A);
                    } 
                    catch (Exception e) 
                    {
                        Log.v("DialogTest", "catch");
                        textX.setText(R.string.dialog_no_wrong_key);
                        showDialog(DIALOG_B);
                    }
                }
            });
4

1 回答 1

3

我认为应该有这样的 onCreateDialog 签名作为链接

@Override
protected Dialog onCreateDialog(int id)

// or

@Override
protected Dialog onCreateDialog(int id, Bundle args)

链接1

于 2012-06-24T12:15:08.053 回答