Só aparece o telefone fixo.
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
View inflate = createView(viewGroup);
Student studentReturn = students.get(position);
connects(inflate, studentReturn);
return inflate;
}
private void connects(View inflate, Student student) {
TextView name = inflate.findViewById(R.id.item_student_name);
name.setText(student.getName());
TextView phone = inflate.findViewById(R.id.item_student_phone);
Telephone firstTelephone = dao.searchFirstTelephone(student.getId());
if (firstTelephone != null){
phone.setText(firstTelephone.getNumber());
}
}
private View createView(ViewGroup viewGroup) {
return LayoutInflater.from(context).inflate(R.layout.item_student, viewGroup, false);
}
public void updates(List<Student> students){
this.students.clear();
this.students.addAll(students);
notifiesAdapter();
}
public void remove(Student student) {
students.remove(student);
Toast.makeText(context, "Aluno removido com sucesso!", Toast.LENGTH_SHORT).show();
notifiesAdapter();
}
private void notifiesAdapter() {
this.notifyDataSetChanged();
}
segue o projeto no git: https://github.com/renanparis/Lista_Alunos_Alura.git