Ao executar o app é me retornado o seguinte erro 'Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference'.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/list_item_foto"
android:layout_width="64dp"
android:layout_height="64dp"
android:src="@drawable/person"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:id="@+id/list_item_nome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nome"
android:textSize="20sp"
android:textStyle="bold"
android:paddingLeft="10dp"/>
<TextView
android:id="@+id/list_item_telefone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telefone"
android:textSize="18sp"
android:paddingLeft="16dp"
android:textStyle="bold"
android:paddingTop="8dp"/>
</LinearLayout>
</LinearLayout>
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Aluno aluno = alunos.get(position);
LayoutInflater inflater = LayoutInflater.from(context);
View view = convertView;
if(view == null){
view = inflater.inflate(R.layout.list_item_alunos, parent, false);
}
TextView campoNome = (TextView) view.findViewById(R.id.list_item_nome);
campoNome.setText(aluno.getNome());
TextView campoTelefone = (TextView) view.findViewById(R.id.list_item_telefone);
campoTelefone.setText(aluno.getTelefone());
ImageView campoFoto = (ImageView) view.findViewById(R.id.list_item_foto);
String caminhoFoto = aluno.getCaminhoFotoAluno();
if(caminhoFoto != null){
Bitmap bitmap = BitmapFactory.decodeFile(caminhoFoto);
Bitmap bitmapReduzido = Bitmap.createScaledBitmap(bitmap, 100, 100,true);
campoFoto.setImageBitmap(bitmapReduzido);
campoFoto.setScaleType(ImageView.ScaleType.FIT_XY);
}
return view;
}