Adapter for a custom layout of listview

前端 未结 3 1590
自闭症患者
自闭症患者 2021-01-25 07:24

I am developing an android project in which I have to load from group of String arrays(say title,description,id) to the listview item TextView.

I did something similar w

相关标签:
3条回答
  • 2021-01-25 07:44

    First of all you need to create a Class that holds that information, something like:

    public class StringHolder{
        String titte;
        String description;
        int id;
    }
    

    Then you create the layout of your row that says where you want your title, your description and your image.

    Then you create an Adapter. The adapter will hold your data and will say for each position in the list what information should be loaded.

    At last you need to use your adapter in an activity.

    For more information you can see a tutorial here: http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/

    0 讨论(0)
  • 2021-01-25 07:45

    If you don't have a cursor, why are you using a SimpleCursorAdapter?

    Read this article about creating a SimpleListView using SimpleAdapter for alternate ideas.

    0 讨论(0)
  • 2021-01-25 07:54

    There are lots of examples of populating lists from various data sources in the ApiDemos project that comes with the Android SDK - browse through those, and you should find one that fits what you're trying to do.

    0 讨论(0)
提交回复
热议问题