Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically adding images to gridview
    text
    copied!<p>How can I dynamically add grid items in grid view? Currently, I have an adapter containing my images. I want to get my images from an URL and dynamically add them to my grid view. I am using following code to download images from url</p> <pre><code> try { URL myFileUrl =null; myFileUrl= new URL(imageUrl); HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bmImg = BitmapFactory.decodeStream(is); //images[i].setImageBitmap(bmImg); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>and the following is mu base image adpater class</p> <pre><code> public class ImageAdapter extends BaseAdapter{ Context mContext; public static final int ACTIVITY_CREATE = 10; public ImageAdapter(Context c){ mContext = c; } @Override public int getCount() { // TODO Auto-generated method stub return 9; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View v; if(convertView==null){ LayoutInflater li = getLayoutInflater(); v = li.inflate(R.layout.icon, null); TextView tv = (TextView)v.findViewById(R.id.icon_text); tv.setText("Profile "+position); ImageView iv = (ImageView)v.findViewById(R.id.icon_image); iv.setImageResource(R.drawable.ondamoveicon); } else { v = convertView; } return v; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return 0; } } </code></pre> <p>Now my problem is that i want to display the images that are download through the url in the adapter. how we will pass these images to adapter class.</p> <p>NOW I am getting the last image on all the places in the gridview</p> <p>Can anyone help me over this Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload