Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ListaAlunosAdapter extends BaseAdapter {
- private final List<Aluno> alunos = new ArrayList<>();
- private Context contexto;
- public ListaAlunosAdapter(Context contexto) {
- this.contexto = contexto;
- }
- @Override
- public int getCount() {
- int size = alunos.size();
- return size;
- }
- @Override
- public Aluno getItem(int position) {
- return alunos.get(position);
- }
- @Override
- public long getItemId(int position) {
- return alunos.get(position).getId();
- }
- @Override
- public View getView(int position, View convertView, ViewGroup groupp) {
- View layout = LayoutInflater.from(this.contexto).inflate(R.layout.item_aluno,groupp, false);
- Aluno aluno = alunos.get(position);
- TextView tvn = layout.findViewById(R.id.item_aluno_nome);
- TextView tvt = layout.findViewById(R.id.item_aluno_telefone);
- tvn.setText(aluno.getNome());
- tvt.setText(aluno.getTelefone());
- return layout;
- }
- public void clear() {
- alunos.clear();
- notifyDataSetChanged();
- }
- public void addAll(List<Aluno> alunos) {
- alunos.addAll(alunos);
- notifyDataSetChanged();
- }
- public void remove(Aluno a) {
- alunos.remove(a);
- notifyDataSetChanged();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement