views:

90

answers:

3

i am new to android. i want to add images in a ListView like below shown links.please help me . view

+1  A: 

In this tutorial you can see how to define a custom ListView. This should help you to implement your own solution.

Roflcoptr
A: 

Here's an efficient implementation of a complex list view by refactoring List Adapter code.

primalpop
A: 

Hi

here is the code which will help u out to add image in list view

public class ItemsList extends ListActivity {

private ItemsAdapter adapter;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

    setContentView(R.layout.items_list);

    this.adapter = new ItemsAdapter(this, R.layout.items_list_item, ItemManager.getLoadedItems());
    setListAdapter(this.adapter);

}

private class ItemsAdapter extends ArrayAdapter {

    private Item[] items;

    public ItemsAdapter(Context context, int textViewResourceId, Item[] items) {
            super(context, textViewResourceId, items);
            this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                    LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.items_list_item, null);
            }

            Item it = items[position];
            if (it != null) {
                    ImageView iv = (ImageView) v.findViewById(R.id.list_item_image);
                    if (iv != null) {
                            iv.setImageDrawable(it.getImage());
                    }
            }

            return v;
    }

}

@Override protected void onListItemClick(ListView l, View v, int position, long id) { this.adapter.getItem(position).click(this.getApplicationContext()); } }

Thanks Rakesh

Rakesh Gondaliya