Comment vérifier si un utilisateur a déjà cliqué sur un Bouton?

J'ai besoin de vérifier si un utilisateur a déjà cliqué sur un bouton... j'ai un bouton dans mon menu avec un “code promo” à l'intérieur... j'ai besoin de vérifier si l'utilisateur a déjà cliqué pour que je puisse lui dire (la prochaine fois qu'il clique dessus) “You already redeemed this promo code!” Comment dois-je faire? J'ai besoin que le morceau de code où je peux vérifier bouton cliqué.

PS: déjà cherché sur le web pour cette!

Merci!

EDIT: mon code ci-dessous. Espérons que ça va aider les autres...

@Override
public boolean onOptionsItemSelected(MenuItem item) {
boolean clicked = false;
switch (item.getItemId()) {
case R.id.getcode: 
SharedPreferences pref = getSharedPreferences("promo", MODE_PRIVATE);
boolean activated = pref.getBoolean("activated", false);
if(activated == false) {  Button btn = (Button) findViewById(R.id.getcode);
AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);
dlgAlert.setMessage(getString(R.string.congrats) + "\n" + getString(R.string.promcd) + "\n" + "ASC2013-"+Build.ID+"-"+android.os.Build.SERIAL.charAt(3)+"-"+Build.SERIAL.charAt(6)+"-"+Build.SERIAL.charAt(9)+"-"+Build.SERIAL.charAt(12));
dlgAlert.setPositiveButton(R.string.go,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.validreq)+Build.BOOTLOADER);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.why) + "\n" + getString(R.string.validreq1) +"\n"+getString(R.string.dialogMSG1);
emailIntent.setType("plain/text");  
startActivity(emailIntent);
}
});
dlgAlert.setCancelable(true);
dlgAlert.create().show(); 
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean("activated", true);
editor.commit();
} 
break;
}
switch (item.getItemId()) {
case R.id.settings: 
Intent settings = new Intent(MainActivity.this, Settings.class);
MainActivity.this.startActivity(settings);
}
return true;
}
InformationsquelleAutor user2606414 | 2013-08-18