1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
public class A extends Activity implements OnClickListener{
//declaration et affection du bouton toto et de la listView list
ListView list;
Button toto;
public void onCreate(Bundle savedInstanceState) {
list = (ListView) findViewById(....);
toto=(Button) findViewById(....);
toto.setOnClickListener(this);
ArrayList<Element> maliste;
//initialisation de la liste
monAdapater = new monAdapter(this, maliste);
list.setAdapter(monAdapter)
}
public void onClick(View v){
if(v == toto){
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setMessage("Do you want to close this window ?").setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'Yes' Button
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'NO' Button
dialog.cancel();
}
});
AlertDialog alert = alt_bld.create();
// Title for AlertDialog
alert.setTitle("Title");
alert.show();
}
}
}//fin de la classe |