How does ArrayAdapter getView() method works?

后端 未结 2 1113
庸人自扰
庸人自扰 2021-02-02 07:03

I want to do an ArrayAdapter to display an image and text. I don\'t want examples if possible. I\'d like someone to explain me how getView() works.

2条回答
  •  滥情空心
    2021-02-02 07:14

    getView() is the main part of your adapter. It returns View that will be displayed as your list/grid/gallary/any view that use adapter item. It triggers when you scroll the view(list for example).

    So the first thing you should do its to create your custom adapter. You may extend it from BaseAdapter. Then you need to create some data to display (or pass it to adapter from out side - its better solution).

    After that override getView() method and make sure to return your custom View there. In your case it should be a Layout with ImageView and TextView (and dont forget to fill them).

    You can learn more from :

    • http://www.youtube.com/watch?v=N6YdwzAvwOA
    • http://www.edureka.in/blog/what-are-adapters-in-android/
    • http://lucasr.org/2012/04/05/performance-tips-for-androids-listview/

提交回复
热议问题