I wanted to use the GetView in Arrayadapter to get the View object for each item in the ListView. As a result, no matter how I make changes to the View object, it doesn't have an effect. Will not change is taken for granted, because GetView, in fact, is "CreateView". Here is the source code I refer to:
public view getview (int position, view convertview, viewgroup parent) { return createviewfromresource (position, Convertview, parent, mresource); } private view createviewfromresource (int position, view convertview, viewgroup parent, int resource) { View view; TextView text; if (convertview == null) { view = minflater.inflate (Resource, parent, false); } else { view = convertview; } try { if (mfieldid == 0) { // if no custom field is assigned, assume the whole resource is a TextView text = (TextView) view; } else { // otherwise, find the textview field within the layout text = (TextView) view.findviewbyid (mfieldid); } } catch (classcastexception e) {    LOG.E ("Arrayadapter", "you must supply a resource id for a textview "); throw new illegalstateexception ( "Arrayadapter requires the resource id to be a textview ", e); } t item = getitem (position); if (item Instanceof charsequence) { Text.settext ((charsequence) Item); } else { text.settext (Item.toString ()); } return view; }
Judging from the code, it must not be what I think. If Convertview equals null, each call to GetView returns a new object. But, why?
My understanding is that adapter, as controller, gets the data down from the model layer and supplies the object up to the view layer. As a giver, you should not be aware of the view layer information. Therefore, it is undesirable to obtain the object of the view layer by adapter.
About the GetView function in Arrayadapter