コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gastos_list);

    alertDialog = Mensajes.crearAlertaDialog(this);
    alertconfirm = Mensajes.crearDialogConfirmacion(this);

    gastosDAO = new GastosDAO(this);
    listaList = gastosDAO.listarGastos();
    adapter = new GastosAdapter(this, listaList);

    lista1 = (ListView) findViewById(R.id.lvlistagast);
    lista1.setAdapter(adapter);
    lista1.setOnItemClickListener(this);
  }
コード例 #2
0
 @Override
 public void onClick(DialogInterface dialog, int which) {
   int id = listaList.get(idok).get_idGast();
   switch (which) {
     case 0:
       Intent intent = new Intent(this, GastosFormActivity.class);
       intent.putExtra("GASTO_ID", id);
       startActivity(intent);
       break;
     case 1:
       alertconfirm.show();
       break;
     case DialogInterface.BUTTON_POSITIVE:
       listaList.remove(idok);
       gastosDAO.eliminarGastos(id);
       lista1.invalidateViews();
       break;
     case DialogInterface.BUTTON_NEGATIVE:
       alertconfirm.dismiss();
       break;
   }
 }