2012-06-24 160 views
1

我剛剛定義了一個對話框作爲android網站的建議,但它不顯示按鈕單擊,一些代碼scracht(我沒有錯誤): static final int DIALOG_A = 1; static final int DIALOG_B = 2; TextView textX;showDialog不顯示自定義對話框

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

編輯您的文章用的ShowDialog()方法的代碼 –

+0

請告訴我常DIALOG_DECRYPT_TEXT指示? –

+0

我剛剛從另一個代碼複製,我打算將其作爲一般示例 – albanx

回答

3

我覺得應該有onCreateDialog的簽名是這樣的link

@Override 
protected Dialog onCreateDialog(int id) 

// or 

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

link1

+0

謝謝@Override忘記(但我不知道我必須放)實際上是問題 – albanx