In the previous Android--listview implementation Simple list, a simple list binding was implemented with Simpleadapter. In this article, it is mainly by rewriting the GetView method, to see what the adapter internal bound data is roughly a process.
First join the implementation class:
Class Mtestadapter extends Simpleadapter {private context context;/* Run Environment */arraylist
We use this implementation class to replace the Simpleadapter we used earlier.
Mtestadapter listitemadapter=new Mtestadapter (Getbasecontext (),/* Indicates the operating environment of the simpleadapter Associated View, which is the current activity*/ listitem,/* A list of maps, each entry in the list corresponds to a row of the ListView, and each map contains all the key*/r.layout.listview_item,/* specified in the FROM parameter The resource ID of the layout file that defines the list item, which should contain at least the id*/new string[]{"ItemName"},/* to be added to the map map, as defined in the to parameter, Key*/new int[] {r.id.name}/* The ID of the view that binds the data corresponds to the from parameter, and the view elements that are bound should be all textview*/);//Set Adapter
After that run, look at the toast we added:
The Click event has been added, and by position, it is easy to distinguish between the item that we are currently working on and the action to be directed against the item. Especially when the item has a button on it, it's easier to rewrite the adapter.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
android--inherits Simpleadapter to rewrite his getview