gpt4 book ai didi

android - showDialog 不显示自定义对话框

转载 作者:行者123 更新时间:2023-11-29 18:10:10 29 4
gpt4 key购买 nike

我只是按照 android 网站的建议定义了一个对话框,但它不会在单击按钮时显示,有些代码是草率的(我没有收到任何错误): 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 签名 link

@Override
protected Dialog onCreateDialog(int id)

// or

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

link1

关于android - showDialog 不显示自定义对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11177335/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com