I am translating a platform from C# to android.
And I am stuck on how to wait for the Dialog response, to determine which action will be done. (It will always bypass the decision.)
I have tried to use handler, but it doesn't work.
Any help is appreciated.
Here are my code, which alertDialog wont wait for Dialog box Response finish.
public boolean CheckWriteCriteria()
{
new AlertDialog.Builder(Labelling.this)
.setTitle("Test 1")
.setMessage("Question_1")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(this, "YES button click ", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(this, "No button click ", Toast.LENGTH_SHORT).show();
}
}).show();
new AlertDialog.Builder(Labelling.this)
.setMessage("Question_2")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
Toast.makeText(this, "YES button click ", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(this, "No button click ", Toast.LENGTH_SHORT).show();
}
}).show();
return true;
}
public void Testing()
{
if(CheckWriteCriteria())
{
Toast.makeText(this, "Testing is before AlertDialog.", Toast.LENGTH_SHORT).show();
}
}