Guest User

Untitled

a guest
Jan 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. private LayoutInflater minflater;
  2. private ArrayList<Utente> utenti;
  3. private int mViewResourceId;
  4.  
  5. TextView Codice,Nome,Cognome,Username,Password;
  6. Button btnelimina;
  7.  
  8. MyDBHelper myDB;
  9.  
  10. String stringa;
  11.  
  12. int deleteCodice;
  13.  
  14.  
  15. public Custom_listAdapter(Context context, int textViewResourceId, ArrayList<Utente> utenti) {
  16. super(context, textViewResourceId, utenti);
  17. this.utenti = utenti;
  18. minflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  19. mViewResourceId = textViewResourceId;
  20. }
  21.  
  22. public View getView (final int position, View convertView, ViewGroup parent) {
  23. convertView = minflater.inflate(mViewResourceId,null);
  24.  
  25. btnelimina = (Button) convertView.findViewById(R.id.belimina);
  26. Utente utente = utenti.get(position);
  27. deleteCodice = position;
  28. stringa = Integer.toString(position);
  29.  
  30. if (utente != null) {
  31. Codice = (TextView) convertView.findViewById(R.id.textCodice);
  32. Nome = (TextView) convertView.findViewById(R.id.textNome);
  33. Cognome = (TextView) convertView.findViewById(R.id.textCognome);
  34. Username = (TextView) convertView.findViewById(R.id.textUsername);
  35. Password = (TextView) convertView.findViewById(R.id.textPassword);
  36.  
  37.  
  38. if (Nome != null) {
  39. Nome.setText(utente.getNome());
  40. }
  41. if (Cognome != null) {
  42. Cognome.setText(utente.getCognome());
  43. }
  44. if (Username != null) {
  45. Username.setText(utente.getUsername());
  46. }
  47. if (Password != null) {
  48. Password.setText(utente.getPassword());
  49. }
  50. if (Codice != null) {
  51. Codice.setText(stringa);
  52. }
  53.  
  54. btnelimina.setOnClickListener(new View.OnClickListener() {
  55. @Override
  56. public void onClick(View v) {
  57.  
  58. myDB.deleteData(deleteCodice);
  59. Intent intent = new Intent(getContext(), Login.class);
  60. getContext().startActivity(intent);
  61. }
  62. });
  63. }
  64. return convertView;
  65. }
Add Comment
Please, Sign In to add comment