Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
233 views
in Technique[技术] by (71.8m points)

android - How does ArrayAdapter getView() method works?

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.

Thanks.

question from:https://stackoverflow.com/questions/6442054/how-does-arrayadapter-getview-method-works

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 :


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...