In Android, making an AlertDialog
with Positive/Negative
buttons is easy.
new AlertDialog.Builder(getActivity())
.setTitle("Question?")
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// User chose YES
}
})
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// User chose NO
}
}).create().show();
I would like to make the equivalent in my TV App. (ask the user a question, get the Yes/No response)
I have found two things, neither of which solve my use case:
ErrorFragment (close, but only has 1 button)
GuidedStepFragment (allows me multiple options, but requires creating a separate Activity, and I have to write my own code to pass the selected choice back to the first Activity)
I feel like i'm missing something. This is only a few lines of code in a normal Android app.
I tried just using AlertDialog
in my TV App, but it throws an error about having the incorrect Theme
set on the App. Plus, I don't think those dialogs are accesibility friendly anyway.