Não consigo encontrar o erro desse código (Erro na parte comentada):
public class AlunoAdapter extends BaseAdapter {
private List<Aluno> listaAlunosBanco;
private Activity activity;
public AlunoAdapter(List<Aluno> listaAlunosBanco, AlunosMainActivity alunosMainActivity) {
this.listaAlunosBanco = listaAlunosBanco;
this.activity = alunosMainActivity;
}
@Override
public int getCount() {
return listaAlunosBanco.size();
}
@Override
public Object getItem(int position) {
return listaAlunosBanco.get(position);
}
@Override
public long getItemId(int position) {
return listaAlunosBanco.get(position).getId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Aluno aluno = listaAlunosBanco.get(position);
LayoutInflater inflater = activity.getLayoutInflater();
View linha = inflater.inflate(R.layout.layout_item, null);
if (position % 2 == 0) {
linha.setBackgroundColor(activity.getResources().getColor(R.color.linha_par));
}
TextView txtLayoutNome = (TextView) linha.findViewById(R.id.edtLayoutNome);
txtLayoutNome.setText(aluno.getNome());
ImageView foto = (ImageView) linha.findViewById(R.id.foto);
// if(aluno.getEnderecoFoto() != null) {
// Bitmap imgBmp = BitmapFactory.decodeFile(aluno.getEnderecoFoto());
// Bitmap imgBmpReduzida = Bitmap.createScaledBitmap(imgBmp, 240, 120, true);
// foto.setImageBitmap(imgBmpReduzida); <<<==== ERRO
// }else {
// foto.setImageResource(R.drawable.skull);
// }
return linha;
}
}
Erro: 09-08 10:27:12.880 21653-21653/com.example.henq.alunos E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at com.example.henq.alunos.AlunoAdapter.getView(AlunoAdapter.java:69)