How is the getView() method used and where is it getting called?

后端 未结 2 1616
梦谈多话
梦谈多话 2021-01-03 21:25

I am new to Android development and have been following the tutorials available on the Android website. I am currently on the section of tutorials for Views, specifically th

相关标签:
2条回答
  • 2021-01-03 21:50

    By setting Adapter, you are telling GridView to fetch views from the Adapter to fill up all the grids. So getView is internally called by GridView to fill up the layout.

    Thats why all the adapters implements Adapter interface so that any AdapterView can request the Adapter.

    0 讨论(0)
  • 2021-01-03 22:01

    Adapter.getView is called inside ObtainView method, inherited from GridView parent class AbsListView, with ScrapView objects passed in when available:

    child = mAdapter.getView(position, scrapView, this);
    

    Then ObtainView is implemented in GridView.onMeasure directly but also in several more callbacks that invoke GridView.layoutChildren, including inherited onTouchEvent method which handles scroll, fling and other touch navigation.

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