在转到下一个编码语句之前,我想知道如何完全执行任何功能。
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);
}