The Current Scenario
I have a gridView in my app and every cell is a custom layout of an image and a text.
When the user touches any cell it opens a dialogue via following code
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
builder.show();
Now the object layout in builder.setView(layout)
has the layout of a imageView , a text box and a button and is set via following code
layout = inflater.inflate(R.layout.buy_set_quantity, null);
Now when the user fills the text box and presses the button I want the alert dialogue to "go away" but I can't find a way to do this.
What have I tried
i tried using builder.dismiss()
but there is no method dismiss for AlertDialog.Builder
type object and the following aswell
cancel();
hide();
remove();
finish();
This question has been asked many times on stack overflow and every one says to use dismiss();
and no answer has been accepted or if there is then how?
How do you dismiss the AlertDialogue.Bulder()
What works?
Pressing the back button (from the three buttons at the bottom of screen in every android) works and the dialogue box is dismissed. But that is not how it should be. So I called the method onBackPressed();
but that not only dismisses the dialogue but also takes the user to the previous activity.
Now does anybody know any new or different method that actually works?