How do you overload a ListView

Posted on 2011-04-30
Last Modified: 2012-05-11

        I was trying to overload a ListView, to include an image downloaded from the net, and have some text next to it.

I've been trying to find a decent tutorial concerning this, but I've only found inconsistent bits and pieces, and I just ended up with a huge project filled with errors.

Could anyone help me out?
Question by:errang
    LVL 17

    Expert Comment

    by:Dejan Pažin

    This shouldnt be that difficult, since it is a very basic functionality. You just need to create custom adapter which extends ArrayAdapter. There you override the method getView and make it return a view that shows the picture and the text.

    There are also planty of tutorials that will show you the complete process. Here is one:

    Author Comment

    I actually tried that site, but it doesn't explain anything about creating a custom adapter... it just has 2 java classes, 1 of which is very basic, and 2 other basic xml files.
    LVL 17

    Expert Comment

    by:Dejan Pažin

    There is a complete explanation of how to make a custom adapter including code for it. The class is named OrderAdapter and it extends ArrayAdapter.

    This is the copied class from the above link:

    private class OrderAdapter extends ArrayAdapter<Order> {
            private ArrayList<Order> items;
            public OrderAdapter(Context context, int textViewResourceId, ArrayList<Order> items) {
                    super(context, textViewResourceId, items);
                    this.items = items;
            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.row, null);
                    Order o = items.get(position);
                    if (o != null) {
                            TextView tt = (TextView) v.findViewById(;
                            TextView bt = (TextView) v.findViewById(;
                            if (tt != null) {
                                  tt.setText("Name: "+o.getOrderName());                            }
                            if(bt != null){
                                  bt.setText("Status: "+ o.getOrderStatus());
                    return v;

    Open in new window


    Author Comment

    Yea, I saw that the final code had all the pieces together, but for some reason it doesn't show me the overloaded ListView, I even copy pasted the code so, there shouldn't be any reason why it doesn't work..
    LVL 17

    Accepted Solution


    The example should work. Did you check the log for any errors.

    If the example doesnt work there must be a reason for it and the best way to check it is to check the log output.

    Author Comment

    Oh... guess one thing I'm actually getting an error with is, this line:


    The time when it actually ran, I scrolled over it, and Eclipse gave me a quick fix of creating the class... but there was nothing in it... shouldn't the ListAdapter do something when its set?

    I don't see that being overloaded in this example.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    I recently asked a question ( about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
    A short article about a problem I had getting the GPS LocationListener working.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now