jeudi 8 janvier 2015

SimpleCursorAdapter GridView with ImageView from sdcard path

I Have the next layout for my GridView



<LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingTop="5dp">
<ImageView
android:id="@+id/grid_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/def_img"
android:background="@drawable/drop_shadow"
android:adjustViewBounds="true">
</ImageView>
<TextView
android:id="@+id/grid_text"
android:ellipsize="start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TITLE"
android:textColor="#cecece"
android:textSize="14sp"
android:singleLine="true"
android:textAllCaps="true"
android:layout_gravity="start"
>
</TextView>


I am trying to populate the GridView from a database i created. The image is stored as a string which contain a path to the image location on the sdcard like so



String iconsStoragePath = Environment.getExternalStorageDirectory() + "/MoviesPosters/myPosters/";
File sdIconStorageDir = new File(iconsStoragePath);
String filePath = sdIconStorageDir.toString() + filename+".png";


Each item on the database has a path with his DbConstants.TITLE in it.


How can i make the adapter to set the image from the sdcard? Thanks.


Aucun commentaire:

Enregistrer un commentaire