0

here is my string which I must work with which is stored in an array called txt

the text and link shows up fine in the gridView cell: public View getView(int position, View convertView, ViewGroup parent) {

 label.setText(Html.fromHtml(txt[position]));

but the problem is, how can i get that image to show ? Here is my xml file located in the menu folder which will fill each individual cell of the gridView:

<ImageView
    android:id="@+id/grid_image"
    android:layout_width="50dp"
    android:layout_height="50dp">
</ImageView>
<TextView
    android:id="@+id/grid_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"
    android:textSize="9sp" >
</TextView>
gaer darrd
  • 35
  • 6

3 Answers3

0

I use AQuery for downloading images from the internet, here is an example of how i do it:

public static void loadImageFromUrl(ImageView imageView, String url) {
    AQuery aq = new AQuery(imageView);
    Bitmap bitmap = aq.getCachedImage(url);
    if (bitmap == null) {
            aq.image(url, memCache, fileCache); //memCache and fileCache are booleans.
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

And in your gridview you call:

 loadImageFromUrl(R.id.grid_image, theUrlOfImage);
JpCrow
  • 4,881
  • 4
  • 32
  • 46
0

You should dowload image from URL and then display it in ImageView. Here is the sample code: How to load an ImageView by URL in Android?

Or you can use library for downloading and displaying images: https://github.com/nostra13/Android-Universal-Image-Loader

Community
  • 1
  • 1
vzoha
  • 151
  • 5
0

You can use Picasso. Code is short and simple and it can handle cache, memory and thread.

If you declare an 'imageView' in the same way you have declared 'label', it's just one row:

Picasso
   .with(context)
   .load(url)
   .into(imageView);
LucianoQ
  • 96
  • 6