title: click on button works for one time
body: <p>i am trying to make a button work for only once, so i did this solution, but sometimes it keeps working for two or more clicks, how to solve that?</p>
  
  <pre><code>              Button bton = (Button)findViewById(R.id.ajoutTroisDemi); 
           bton.setOnClickListener(new View.OnClickListener() {  
            @Override
               public void onClick(View v) {
                v.setClickable(false);
                v.setEnabled(false);
                  ajouter(v);
                  Intent l = new Intent(ActivityTroisQuart.this,ActivityTroisDemi.class);
                  startActivity(l);
                  Toast.makeText(getApplicationContext(), "Données Enregistrées", Toast.LENGTH_SHORT).show();
               }
  
          public void  ajouter(View v) {
              db.open();
            EditText     rm_26 = (EditText)findViewById(R.id.rm_26);
            String       rm_26_1ts = rm_26.getText().toString();
            SharedPreferences prefs4 = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
            prefs4.edit().putString(Ordr, rm_26_1ts).commit();   
          int nb = prefs4.getInt(B, 0);              
              long id = prefs4.getLong(ID, 0);
              db.insertMMbreMenage1(id,rm_26_1ts);
                 int test = nb-1;
                 Editor editor = prefs4.edit();
                 editor.putInt("nb", test);
                 editor.commit();
  
              db.close();                     
              } 
   });
  </code></pre>