Answer the question
In order to leave comments, you need to log in
How to handle click of alertDialog button?
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder.setView(promptsView);
builder.setTitle("Введите имя пользователя")
// .setMessage("Введите имя")
.setCancelable(false)
.setPositiveButton("ОК",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (userInput.getText().toString().equals(""))
{
Toast toast = Toast.makeText(view.getContext(),
"Заполните поля!", Toast.LENGTH_SHORT);
toast.show();
}else {
dialog.cancel();
}
}
});
AlertDialog alert = builder.create();
alert.show();
Answer the question
In order to leave comments, you need to log in
First define a dialog with an empty onClick
And then override onClick further:
adb.setView(view).setTitle(R.string.fw)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
//Ничего здесь не определеяем
}
});
Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
positiveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Пишите тут свою логику
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question