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);
}
}
});
編輯您的文章用的ShowDialog()方法的代碼 –
請告訴我常DIALOG_DECRYPT_TEXT指示? –
我剛剛從另一個代碼複製,我打算將其作爲一般示例 – albanx