As I said in the title, I have 2 alert dialogs showing on user interaction. I have menu that has 4 options: Settings, Credits, Promocode and Exit one, but when I click on Promocode, I got an error mentioned in the question. This is my code:
switch ((int) mMergeAdapter.getItemId(position)) {
case 0:
Intent intent2 = new Intent(Browser.this,
SettingsActivity.class);
startActivity(intent2);
break;
case 1:
AlertDialog.Builder builder = new AlertDialog.Builder(Browser.this);
builder.setTitle("Credits");
builder.setMessage("Code\n\nTraabefi\n\nDesign\n\nSamuel 'Samael' Chmura");
builder.setIcon(R.drawable.holo_dark_action_info);
builder.setPositiveButton("OK", null);
AlertDialog dialog = builder.create();
dialog.show();
TextView txt = (TextView)dialog.findViewById(android.R.id.message);
txt.setGravity(Gravity.CENTER);
break;
case 2:
AlertDialog.Builder alert = new AlertDialog.Builder(Browser.this);
alert.setTitle("Enter your promocode.");
final EditText input = (EditText) findViewById(android.R.id.edit);
alert.setView(input);
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
if (input.getText().toString()=="abcd"){
isPremium = true;
}
else {
isPremium = false;
}}});
alert.show();
break;
case 3:
finish();
}
0 comments:
Post a Comment