I'm trying to show an image that is stored in the "drawable" folder and I'm using'setImageURI 'but for some reason I'm not sure the code is not working for me.
The information that I am uploading in the app is from a json file in which I have the name, location and address of the image.
to get the address of the image I'm using the method, which gives me a string with the address of the image.
student.getImage ();
Thanks to Julian I know that I can use: NuevaView.imagen.setImageResource (R.drawable.ci); to load the image, but it would always be the same image for all. There is some way to load the address of each image.
Try using setImageURI but I do not see anything in the palicacion, I leave blank the section of the image .. the json file has 20 members each with its name, location and a single image assigned to each one.
Something idea how I can solve this problem.
String img = estudiante.getImagen();
File imagenArchivo= new File(img);
NuevaView.imagen.setImageURI(Uri.fromFile(imagenArchivo));
Here is the ImageView that I am using
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".1"
app:srcCompat="@drawable/cc"/>
and here the code to show the image
if (vista== null) {
vista= inflater.inflate(R.layout.lista, viewGroup, false);
NuevaView= new NewView();
NuevaView.nombre= (TextView) vista.findViewById(R.id.Nombre);
NuevaView.locacion = (TextView) vista.findViewById(R.id.Locacion);
NuevaView.imagen = (ImageView) vista.findViewById(R.id.imageView);
vista.setTag(NewView);
} else
NewView = (NewView) view.getTag();
NuevaView.name.setText(estudiante.getNombre());
NuevaView.location.setText(estudiante.getLocacion());
String img = estudiante.getImagen();
File imagenArchivo= new File(img);
NuevaView.imagen.setImageURI(Uri.fromFile(imagenArchivo));
return vista;
}
public class NuevaView{
TextView nombre;
TextView locacion;
ImageView imagen;
}