Good evening. I'm having trouble with this error, I'm not able to find out why the object is null. The error is in the last line of the code. I'm using it in a fragment.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
cartas = view.findViewById(R.id.cartas_imagem);
cartas.setImageResource(cartasArray[position]);
}
Here's my list:
final int[] cartasArray = {R.drawable.amizade, R.drawable.ilusao_menor, R.drawable.maos_magicas,
R.drawable.prestidigitacao, R.drawable.protecao_contra_laminas, R.drawable.rajada_de_veneno,
R.drawable.rajada_mistica, R.drawable.toque_arrepiante};
Thank you in advance.