Android Studio 3.0.1
It works in QAnswerQuestion.java code
List<Integer> wrongList = UIResponse.checkAnswer(list);
if (wrongList.size() == 0)
{
new AlertDialog.Builder(QAnswerQuestion.this).setTitle("Info")
.setMessage("You are awesome and all answers are correct!")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
}).setNegativeButton("Cancel", null).show();
}
but when I try to put the above code in UIResponse.java
and call in QAnswerQuestion.java like this:
UIResponse.lastQuestionDialog(QAnswerQuestion.this,list);
and UIResponse.java code is
static void lastQuestionDialog(final Context context, List<Question> list)
{
List<Integer> wrongList = UIResponse.checkAnswer(list);
if (wrongList.size() == 0)
{
new AlertDialog.Builder(context).setTitle("Info")
.setMessage("You are awesome and all answers are correct!")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
finish();
}
}).setNegativeButton("Cancel", null).show();
}
}
It says "can't resolve finish methods "