次のコーディングステートメントに進む前に、関数を完全に実行する方法を知りたいです。
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btnBack:
i = new Intent(SetUpActivity.this, HomeActivity.class);
finish();
break;
case R.id.btnOne:
showDisclaimerDialog();
Log.d("agreed value", agreed+"");
if (agreed) {
Log.e("Inside", "btnOne");
appObj.setMaxFeeds(1);
i = new Intent(SetUpActivity.this, SelectFeedsActivity.class);
startActivity(i);
}
break;
case R.id.btnTwo:
showDisclaimerDialog();
if(agreed) {
appObj.setMaxFeeds(2);
i = new Intent(SetUpActivity.this, SelectFeedsActivity.class);
startActivity(i);
}
break;
case R.id.btnFive:
showDisclaimerDialog();
if (agreed) {
appObj.setMaxFeeds(5);
i = new Intent(SetUpActivity.this, SelectFeedsActivity.class);
startActivity(i);
}
break;
default:
break;
}
private void showDisclaimerDialog() {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new AlertDialog.Builder(
SetUpActivity.this);
builder.setTitle("Disclaimer");
builder.setMessage(Html.fromHtml(getString(R.string.disclaimer)));
builder.setPositiveButton("I Agree",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
agreed = true;
Log.e("Inside I agree",agreed+"");
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
agreed = false;
Log.e("Inside Cancel",agreed+"");
}
});
builder.create().show();
agreed=false;
Log.e("Inside dialog",agreed+"");
}
「btnOne」をクリックすると、実行の制御は「showDiclaimerDialog()」に移動しますが、それ以上のステートメントは実行されません。
Log.d("agreed value", agreed+"");
if (agreed) {
Log.e("Inside", "btnOne");
appObj.setMaxFeeds(1);
i = new Intent(SetUpActivity.this, SelectFeedsActivity.class);
startActivity(i);
}