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
//系统调用此方法,用来获知模型层有多少条数据 @Override publicintgetCount() { return people.size(); }
//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"