Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private LayoutInflater minflater;
- private ArrayList<Utente> utenti;
- private int mViewResourceId;
- TextView Codice,Nome,Cognome,Username,Password;
- Button btnelimina;
- MyDBHelper myDB;
- String stringa;
- int deleteCodice;
- public Custom_listAdapter(Context context, int textViewResourceId, ArrayList<Utente> utenti) {
- super(context, textViewResourceId, utenti);
- this.utenti = utenti;
- minflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mViewResourceId = textViewResourceId;
- }
- public View getView (final int position, View convertView, ViewGroup parent) {
- convertView = minflater.inflate(mViewResourceId,null);
- btnelimina = (Button) convertView.findViewById(R.id.belimina);
- Utente utente = utenti.get(position);
- deleteCodice = position;
- stringa = Integer.toString(position);
- if (utente != null) {
- Codice = (TextView) convertView.findViewById(R.id.textCodice);
- Nome = (TextView) convertView.findViewById(R.id.textNome);
- Cognome = (TextView) convertView.findViewById(R.id.textCognome);
- Username = (TextView) convertView.findViewById(R.id.textUsername);
- Password = (TextView) convertView.findViewById(R.id.textPassword);
- if (Nome != null) {
- Nome.setText(utente.getNome());
- }
- if (Cognome != null) {
- Cognome.setText(utente.getCognome());
- }
- if (Username != null) {
- Username.setText(utente.getUsername());
- }
- if (Password != null) {
- Password.setText(utente.getPassword());
- }
- if (Codice != null) {
- Codice.setText(stringa);
- }
- btnelimina.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- myDB.deleteData(deleteCodice);
- Intent intent = new Intent(getContext(), Login.class);
- getContext().startActivity(intent);
- }
- });
- }
- return convertView;
- }
Add Comment
Please, Sign In to add comment