私はユーザに表示するメッセージのリストを持っています。これらは配列に格納されます。私はアラートを表示したいと思うし、ユーザーが正のボタンをクリックすると、メッセージを1つずつ調べます。各クリックでAndroidがAlertDialogテキストを変更しています
_msgCountは、私のクラスのプライベート変数です。
msgsは最終的な最終変数です。
すべてのログが記録されます。しかし、メッセージは変わらない。 _alert.hide()、setMessage()、そして_alert.show()もやってみました。
ありがとうございました!
AlertDialog.Builder builder = new AlertDialog.Builder(this);
_alert = builder.setTitle("Whoa there!")
.setMessage(msgs[_msgCount])
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
Log.i("EasterHunt", "On positive click");
_alert.setMessage(msgs[++_msgCount]);
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
Log.i("EasterHunt", "On negative click");
Toast.makeText(MapsMarkerActivity.this, R.string.nope, Toast.LENGTH_SHORT).show();
}
})
.create();
_alert.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog)
{
Log.i("EasterHunt", "what!");
}
});
あなたは次のようなものを試してみましたか?dialogInterface.setMessage(msgs [++ _ msgCount]); –
このような(AlertDialog)dialogInterface.setMessage(msgs [++ _ msgCount]); https://developer.android.com/reference/android/app/AlertDialog.html –