Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. //ma fonction appui long sur ma listview
  2.  mRecetteList.setOnItemLongClickListener(new OnItemLongClickListener() {
  3.              public boolean onItemLongClick(AdapterView parent, View v, int position, long id) {
  4.                 ilaposition=position;
  5.              //création d'un boite de dialogue pour confirmer le choix
  6.              new AlertDialog.Builder(EnregRecette.this)
  7.                  .setTitle("Confirmation")
  8.                  .setMessage("Voulez vous supprimer cet ingredient de la liste")
  9.                  .setPositiveButton("OUI", new DialogInterface.OnClickListener()
  10.                  {
  11.                       public void onClick(DialogInterface dialog, int whichButton)
  12.                       {
  13.                          aTableauIngredientaff.remove(ilaposition);
  14.                         aTableauIngredient.remove(ilaposition);
  15.                         mRecetteList = (ListView) findViewById(android.R.id.list);
  16.                         final ArrayAdapter adapter2 = new ArrayAdapter(getBaseContext(),
  17.                                     android.R.layout.simple_list_item_1,aTableauIngredientaff);
  18.                         mRecetteList.setAdapter(adapter2);
  19.                       }
  20.                  })
  21.                  .setNegativeButton("NON", new DialogInterface.OnClickListener() {
  22.                  public void onClick(DialogInterface dialog, int whichButton) {
  23.                      /* User clicked Cancel so do some stuff */
  24.                  }
  25.              })
  26.                  .show();
  27.                  return true;
  28.              }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement