boutons et boite de dialogue
Bonjour
Sur mon actvity :
Code:
public class lyfiche extends Activity implements android.view.View.OnClickListener{
j'ai quatre imageButton
Code:
1 2 3 4
| ((ImageButton)this.findViewById(R.id.btntel)).setOnClickListener(this);
((ImageButton)this.findViewById(R.id.btnmail)).setOnClickListener(this);
((ImageButton)this.findViewById(R.id.btncontact)).setOnClickListener(this);
((ImageButton)this.findViewById(R.id.btnfavori)).setOnClickListener(this); |
Je récuprère le clic comme suit
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public void onClick(View v) {
switch(v.getId()){
case R.id.btncontact:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Ajouter à mes contacts ?")
.setCancelable(false)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
case R.id.btnfavori:
.............................. |
Quand je clic la boite de dialogue ne s'affiche pas
Merci pour la solution