"Android-005" "ListView"

Source: Internet
Author: User

Project Source Download ListView
    • Is the one that shows the entries for a row.
    • MVC structure
      • M:model model layer, the data to be displayed ———— people collection
      • V:view view layer, the user sees the interface ———— ListView
      • C:control control layer, manipulating how data is displayed ———— adapter object
    • Each entry is a View object
Baseadapter
    • Two methods that must be implemented

    • First one

            //系统调用此方法,用来获知模型层有多少条数据            @Override            publicintgetCount() {                return people.size();            }
    • A second
 //system call this method to get the view object to display to the ListView  //position: The position of the data corresponding to the return view object in the collection  @Override  View getview  (int  position, view Convertview, ViewGroup parent) {System.. println ( "GetView method call"  + position); TextView TV = new  TextView (mainactivity. This ); //gets the element in the collection  Person p = people. get  (position); Tv.settext (P.tostring ()); //returns the TextView object, it becomes the entry for the ListView  return  TV; }
    • How many entries can be displayed on the screen, how many times the GetView method will be called, and when the screen is sliding down, GetView will continue to be called, creating more View objects to display to the screen
Cache of Entries
    • When the entry is a screen, the system will cache the entry into memory, when the entry again into the screen, the system will re-call GetView when the cache entry as the Convertview parameter, but the incoming entry is not necessarily the previously cached entry, That is, it is possible for the system to pass the cache of any entry when it calls the GetView method to get the first entry

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Android-005" "ListView"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.