簡體   English   中英

showDialog不顯示自定義對話框

[英]showDialog doesn't show custom dialog

我剛剛定義了一個對話框作為android網站建議,但它沒有顯示按鈕點擊,一些代碼scracht(我沒有得到任何錯誤):static final int DIALOG_A = 1; static final int DIALOG_B = 2; TextView textX;

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);
                    }
                }
            });

我認為onCreateDialog應該像這樣簽名作為鏈接

@Override
protected Dialog onCreateDialog(int id)

// or

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

鏈接1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM