我一直在浏览示例和教程,但我似乎无法理解如何在子类 SimpleCursorAdapter 中处理回收。我知道对于常规的 ArrayAdapters,您可以检查 convertView 是否为 null,如果从 xml 中为 null,则为 null,如果不为 null,则进行回收,但我在可视化它如何与 SimpleCursorAdapter 子类中的 from 和 to 数组一起工作时遇到了一些麻烦。我试图从 Commonsware 的 The Busy Coders Guide to Android Development 中弄清楚这一点,但没有成功。如果有人知道任何提示、示例或教程,我将不胜感激。
5 回答
我找不到任何对 SimpleCursorAdapter 进行子类化以使用 convertView 回收方法的好的示例,因此我最终改为对 CursorAdapter 进行子类化。这实际上对我的实现非常有效,并且随着内存使用量的显着减少而飞速发展。回收视图确实有效,我强烈推荐它!
这是我的实现示例:
private static class MyNiftyAdapter extends CursorAdapter
{
private LayoutInflater mInflater;
private Cursor cur;
public MyNiftyAdapter(Context context, Cursor c) {
super(context,c);
this.mInflater = LayoutInflater.from(context);
this.cur = c;
}
public MyNiftyAdapter(Context context, Cursor c, boolean autoRequery)
{
super(context, c, autoRequery);
this.mInflater = LayoutInflater.from(context);
this.cur = c;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder viewHolder;
if(convertView == null)
{
convertView = this.mInflater.inflate(R.layout.chamber_item, null);
viewHolder = new ViewHolder();
viewHolder.name = (TextView)convertView.findViewById(R.id.Name);
viewHolder.city = (TextView)convertView.findViewById(R.id.city);
viewHolder.state = (TextView)convertView.findViewById(R.id.state);
viewHolder.country = (TextView)convertView.findViewById(R.id.country);
convertView.setTag(viewHolder);
}else
{
viewHolder = (ViewHolder)convertView.getTag();
}
this.cur.moveToPosition(position);
viewHolder.name.setText(this.cur.getString(this.cur.getColumnIndex(MyDBHelper.NAME)));
viewHolder.city.setText(this.cur.getString(this.cur.getColumnIndex(MyDBHelper.CITY)));
viewHolder.state.setText(this.cur.getString(this.cur.getColumnIndex(MyDBHelper.STATE)));
viewHolder.country.setText(this.cur.getString(this.cur.getColumnIndex(MyDBHelper.COUNTRY)));
return convertView;
}
/* (non-Javadoc)
* @see android.widget.CursorAdapter#bindView(android.view.View, android.content.Context, android.database.Cursor)
*/
@Override
public void bindView(View view, Context context, Cursor cursor) {
// Dont need to do anything here
}
/* (non-Javadoc)
* @see android.widget.CursorAdapter#newView(android.content.Context, android.database.Cursor, android.view.ViewGroup)
*/
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// Dont need to do anything here either
return null;
}
static class ViewHolder
{
TextView name;
TextView city;
TextView state;
TextView country;
}
}
现在,我列表中的每一行都完全按照我的意愿显示名称、城市、州和国家/地区。希望这可以帮助。
CursorAdapter 为您完成部分工作。您只需要在需要创建新视图时重写 newView() ,并在回收现有视图时重写 bindView() 。
import java.util.ArrayList;
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class AccountsAdapter extends CursorAdapter {
public static final String TAG = AccountsAdapter.class.getSimpleName();
private Boolean DEBUG=true;
private LayoutInflater mInflater;
private int layoutResource;
private Cursor mCursor;
private int acctInd;
private int upicInd;
private ViewHolder holder;
public AccountsAdapter(Context context,Cursor c,int resourceId) {
super(context,c);
this.mCursor=c;
acctInd=mCursor.getColumnIndex(LJDB.KEY_JOURNALNAME);
upicInd=mCursor.getColumnIndex(LJDB.KEY_DEFAULTUSERPIC);
this.layoutResource=resourceId;
this.mInflater = LayoutInflater.from(context);
}
private static class ViewHolder {
ImageView userpic;
TextView journalname;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
holder = (ViewHolder) view.getTag();
holder.journalname.setText(cursor.getString(acctInd));
holder.userpic.setTag(cursor.getString(upicInd));
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View v = mInflater.inflate(layoutResource, null);
holder = new ViewHolder();
holder.userpic = (ImageView) v.findViewById(R.id.duserpic);
holder.journalname = (TextView) v.findViewById(R.id.uname);
v.setTag(holder);
return v;
} }
您也可以继承ResourceCursorAdapter。在这种情况下,您只需要覆盖 bindview 方法:
public class MySimpleCursorAdapter extends ResourceCursorAdapter {
public MySimpleCursorAdapter(Context context, Cursor c) {
super(context, R.layout.myLayout, c);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
ViewHolder viewHolder = (ViewHolder) view.getTag();
if (viewHolder == null) {
viewHolder = new ViewHolder(view);
view.setTag(viewHolder);
}
viewHolder.bind(cursor, context);
}
/**
* A ViewHolder keeps references to children views to avoid unnecessary calls
* to findViewById() on each row (especially during scrolling)
*/
private static class ViewHolder {
private TextView text;
private ToggleButton toggle;
public ViewHolder(View view) {
text = (TextView) view.findViewById(R.id.rowText);
toggle = (ToggleButton) view.findViewById(R.id.rowToggleButton);
}
/**
* Bind the data from the cursor to the proper views that are hold in
* this holder
* @param cursor
*/
public void bind(Cursor cursor, Context context) {
toggle.setChecked(0 != cursor.getInt(cursor.getColumnIndex("ENABLED")));
text.setText(cursor.getString(cursor.getColumnIndex("TEXT")));
}
}
}
根据我的测试,似乎接受的答案是不正确的(更多的是,不必要的)。
据我所知(基于简单的 Log.e 输出测试),默认情况下会正确处理视图回收(如@Romain Guy 所述)。我认为这可以证明没有建议您需要在我遇到的任何文档中覆盖getView() 。
这是我用来得出这个结论的简单示例中使用的代码片段:
public class MediaAdapter extends CursorAdapter {
@Override
public void bindView(View arg0, Context arg1, Cursor arg2) {
Log.e("bindView", "Called: " + arg2.getPosition());
ImageView iv = (ImageView) arg0;
iv.setImageDrawable(new BitmapDrawable(getResources(), MediaStore.Images.Thumbnails.getThumbnail(arg1.getContentResolver(),
arg2.getInt(arg2.getColumnIndex(MediaStore.Images.Media._ID)), MediaStore.Images.Thumbnails.MICRO_KIND, null)));
}
@Override
public View newView(Context arg0, Cursor arg1, ViewGroup arg2) {
Log.e("newView", "Called: " + arg1.getPosition());
ImageView iv = new ImageView(ctFrag);
iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT, 96));
iv.setPadding(Spine.getDp(2), Spine.getDp(2), Spine.getDp(2), Spine.getDp(2));
return iv;
}
}
在 GridView 中使用它来显示可用的图像缩略图网格时,LogCat 输出如下:
06-11 21:50:09.906: E/newView(3192): Called: 0
06-11 21:50:09.906: E/bindView(3192): Called: 0
06-11 21:50:09.929: E/bindView(3192): Called: 0
06-11 21:50:09.937: E/bindView(3192): Called: 0
06-11 21:50:09.945: E/bindView(3192): Called: 0
06-11 21:50:09.953: E/bindView(3192): Called: 0
06-11 21:50:09.968: E/bindView(3192): Called: 0
06-11 21:50:09.984: E/bindView(3192): Called: 0
06-11 21:50:10.000: D/dalvikvm(3192): GC_CONCURRENT freed 555K, 5% free 14670K/15303K, paused 1ms+6ms
06-11 21:50:10.023: E/bindView(3192): Called: 0
06-11 21:50:10.031: E/bindView(3192): Called: 0
06-11 21:50:10.047: E/newView(3192): Called: 1
06-11 21:50:10.047: E/bindView(3192): Called: 1
06-11 21:50:10.062: E/newView(3192): Called: 2
06-11 21:50:10.062: E/bindView(3192): Called: 2
06-11 21:50:10.070: E/newView(3192): Called: 3
06-11 21:50:10.070: E/bindView(3192): Called: 3
06-11 21:50:10.078: E/newView(3192): Called: 4
06-11 21:50:10.078: E/bindView(3192): Called: 4
06-11 21:50:10.086: E/newView(3192): Called: 5
06-11 21:50:10.086: E/bindView(3192): Called: 5
06-11 21:50:10.093: E/newView(3192): Called: 6
06-11 21:50:10.093: E/bindView(3192): Called: 6
06-11 21:50:10.093: E/newView(3192): Called: 7
06-11 21:50:10.093: E/bindView(3192): Called: 7
06-11 21:50:10.101: E/newView(3192): Called: 8
06-11 21:50:10.101: E/bindView(3192): Called: 8
06-11 21:50:10.101: E/newView(3192): Called: 9
06-11 21:50:10.101: E/bindView(3192): Called: 9
06-11 21:50:10.125: E/newView(3192): Called: 10
06-11 21:50:10.125: E/bindView(3192): Called: 10
06-11 21:50:10.133: E/newView(3192): Called: 11
06-11 21:50:10.133: E/bindView(3192): Called: 11
06-11 21:50:10.140: D/dalvikvm(3192): GC_CONCURRENT freed 351K, 3% free 15001K/15431K, paused 1ms+2ms
06-11 21:50:10.140: E/newView(3192): Called: 12
06-11 21:50:10.140: E/bindView(3192): Called: 12
06-11 21:50:10.164: E/newView(3192): Called: 13
06-11 21:50:10.164: E/bindView(3192): Called: 13
06-11 21:50:10.179: E/newView(3192): Called: 14
06-11 21:50:10.179: E/bindView(3192): Called: 14
06-11 21:50:10.187: E/newView(3192): Called: 15
06-11 21:50:10.187: E/bindView(3192): Called: 15
06-11 21:50:10.195: E/newView(3192): Called: 16
06-11 21:50:10.195: E/bindView(3192): Called: 16
06-11 21:50:10.203: E/newView(3192): Called: 17
06-11 21:50:10.203: E/bindView(3192): Called: 17
06-11 21:50:10.211: E/newView(3192): Called: 18
06-11 21:50:10.211: E/bindView(3192): Called: 18
06-11 21:50:10.218: E/newView(3192): Called: 19
06-11 21:50:10.218: E/bindView(3192): Called: 19
06-11 21:50:10.218: E/newView(3192): Called: 20
06-11 21:50:10.218: E/bindView(3192): Called: 20
06-11 21:50:10.218: E/newView(3192): Called: 21
06-11 21:50:10.218: E/bindView(3192): Called: 21
06-11 21:50:10.226: E/newView(3192): Called: 22
06-11 21:50:10.226: E/bindView(3192): Called: 22
06-11 21:50:10.226: E/newView(3192): Called: 23
06-11 21:50:10.226: E/bindView(3192): Called: 23
06-11 21:50:10.234: E/newView(3192): Called: 24
06-11 21:50:10.234: E/bindView(3192): Called: 24
06-11 21:50:10.234: E/newView(3192): Called: 25
06-11 21:50:10.234: E/bindView(3192): Called: 25
06-11 21:50:10.242: E/newView(3192): Called: 26
06-11 21:50:10.242: E/bindView(3192): Called: 26
06-11 21:50:10.242: E/newView(3192): Called: 27
06-11 21:50:10.242: E/bindView(3192): Called: 27
06-11 21:50:10.250: D/dalvikvm(3192): GC_CONCURRENT freed 247K, 2% free 15582K/15879K, paused 1ms+1ms
06-11 21:50:10.250: E/newView(3192): Called: 28
06-11 21:50:10.250: E/bindView(3192): Called: 28
06-11 21:50:10.265: E/newView(3192): Called: 29
06-11 21:50:10.265: E/bindView(3192): Called: 29
06-11 21:50:10.265: E/newView(3192): Called: 30
06-11 21:50:10.265: E/bindView(3192): Called: 30
06-11 21:50:10.273: E/newView(3192): Called: 31
06-11 21:50:10.273: E/bindView(3192): Called: 31
06-11 21:50:10.273: E/newView(3192): Called: 32
06-11 21:50:10.273: E/bindView(3192): Called: 32
06-11 21:50:10.281: E/newView(3192): Called: 33
06-11 21:50:10.281: E/bindView(3192): Called: 33
06-11 21:50:10.281: E/newView(3192): Called: 34
06-11 21:50:10.281: E/bindView(3192): Called: 34
06-11 21:50:10.289: E/newView(3192): Called: 35
06-11 21:50:10.289: E/bindView(3192): Called: 35
06-11 21:50:10.289: E/newView(3192): Called: 36
06-11 21:50:10.289: E/bindView(3192): Called: 36
06-11 21:50:10.297: E/newView(3192): Called: 37
06-11 21:50:10.297: E/bindView(3192): Called: 37
06-11 21:50:10.297: E/newView(3192): Called: 38
06-11 21:50:10.297: E/bindView(3192): Called: 38
06-11 21:50:10.297: E/newView(3192): Called: 39
06-11 21:50:10.297: E/bindView(3192): Called: 39
06-11 21:50:10.304: E/newView(3192): Called: 40
06-11 21:50:10.304: E/bindView(3192): Called: 40
06-11 21:50:10.304: E/newView(3192): Called: 41
06-11 21:50:10.304: E/bindView(3192): Called: 41
06-11 21:50:10.312: E/newView(3192): Called: 42
06-11 21:50:10.312: E/bindView(3192): Called: 42
06-11 21:50:10.312: E/newView(3192): Called: 43
06-11 21:50:10.312: E/bindView(3192): Called: 43
06-11 21:50:10.320: E/newView(3192): Called: 44
06-11 21:50:10.320: E/bindView(3192): Called: 44
06-11 21:50:10.336: E/newView(3192): Called: 45
06-11 21:50:10.336: E/bindView(3192): Called: 45
06-11 21:50:10.343: E/newView(3192): Called: 46
06-11 21:50:10.343: E/bindView(3192): Called: 46
06-11 21:50:10.351: D/dalvikvm(3192): GC_CONCURRENT freed 301K, 3% free 16297K/16647K, paused 1ms+3ms
06-11 21:50:10.351: E/newView(3192): Called: 47
06-11 21:50:10.351: E/bindView(3192): Called: 47
06-11 21:50:10.351: E/newView(3192): Called: 48
06-11 21:50:10.359: E/bindView(3192): Called: 48
06-11 21:50:10.367: E/newView(3192): Called: 49
06-11 21:50:10.367: E/bindView(3192): Called: 49
06-11 21:50:10.383: E/newView(3192): Called: 50
06-11 21:50:10.383: E/bindView(3192): Called: 50
06-11 21:50:10.390: E/newView(3192): Called: 51
06-11 21:50:10.390: E/bindView(3192): Called: 51
06-11 21:50:10.406: E/newView(3192): Called: 52
06-11 21:50:10.406: E/bindView(3192): Called: 52
06-11 21:50:10.414: E/newView(3192): Called: 53
06-11 21:50:10.414: E/bindView(3192): Called: 53
06-11 21:50:10.422: E/newView(3192): Called: 54
06-11 21:50:10.422: E/bindView(3192): Called: 54
06-11 21:50:10.422: E/newView(3192): Called: 55
06-11 21:50:10.422: E/bindView(3192): Called: 55
06-11 21:50:10.429: E/newView(3192): Called: 56
06-11 21:50:10.429: E/bindView(3192): Called: 56
06-11 21:50:10.437: E/newView(3192): Called: 57
06-11 21:50:10.437: E/bindView(3192): Called: 57
06-11 21:50:10.453: E/newView(3192): Called: 58
06-11 21:50:10.453: E/bindView(3192): Called: 58
06-11 21:50:10.461: E/newView(3192): Called: 59
06-11 21:50:10.461: E/bindView(3192): Called: 59
06-11 21:50:10.468: E/newView(3192): Called: 60
06-11 21:50:10.468: E/bindView(3192): Called: 60
06-11 21:50:10.484: E/newView(3192): Called: 61
06-11 21:50:10.484: E/bindView(3192): Called: 61
06-11 21:50:10.492: E/newView(3192): Called: 62
06-11 21:50:10.492: E/bindView(3192): Called: 62
06-11 21:50:10.508: E/newView(3192): Called: 63
06-11 21:50:10.508: E/bindView(3192): Called: 63
06-11 21:50:10.515: E/newView(3192): Called: 64
06-11 21:50:10.515: E/bindView(3192): Called: 64
06-11 21:50:10.523: E/newView(3192): Called: 65
06-11 21:50:10.523: E/bindView(3192): Called: 65
06-11 21:50:10.539: E/newView(3192): Called: 0
06-11 21:50:10.539: E/bindView(3192): Called: 0
06-11 21:50:10.547: E/bindView(3192): Called: 0
06-11 21:50:10.547: E/bindView(3192): Called: 0
06-11 21:50:10.578: E/bindView(3192): Called: 0
06-11 21:50:10.593: D/dalvikvm(3192): GC_CONCURRENT freed 392K, 3% free 17115K/17543K, paused 2ms+7ms
06-11 21:50:10.601: E/bindView(3192): Called: 0
06-11 21:50:10.609: E/bindView(3192): Called: 0
06-11 21:50:10.625: E/bindView(3192): Called: 0
06-11 21:50:10.633: E/bindView(3192): Called: 0
06-11 21:50:14.586: D/dalvikvm(3192): GC_FOR_ALLOC freed 307K, 4% free 18033K/18695K, paused 14ms
06-11 21:50:14.632: D/dalvikvm(3192): GC_FOR_ALLOC freed 2K, 3% free 19439K/19911K, paused 11ms
06-11 21:50:14.632: E/bindView(3192): Called: 66
06-11 21:50:14.640: E/bindView(3192): Called: 67
06-11 21:50:14.640: E/bindView(3192): Called: 68
06-11 21:50:14.648: E/bindView(3192): Called: 69
06-11 21:50:14.648: E/bindView(3192): Called: 70
06-11 21:50:14.656: E/bindView(3192): Called: 71
06-11 21:50:14.656: E/bindView(3192): Called: 72
06-11 21:50:14.664: E/bindView(3192): Called: 73
06-11 21:50:14.664: E/bindView(3192): Called: 74
06-11 21:50:14.672: E/bindView(3192): Called: 75
06-11 21:50:14.672: E/bindView(3192): Called: 76
06-11 21:50:14.679: E/bindView(3192): Called: 77
06-11 21:50:14.679: E/bindView(3192): Called: 78
06-11 21:50:14.687: E/newView(3192): Called: 79
06-11 21:50:14.687: E/bindView(3192): Called: 79
06-11 21:50:14.687: E/newView(3192): Called: 80
06-11 21:50:14.687: E/bindView(3192): Called: 80
06-11 21:50:14.687: E/newView(3192): Called: 81
06-11 21:50:14.687: E/bindView(3192): Called: 81
06-11 21:50:14.695: E/newView(3192): Called: 82
06-11 21:50:14.695: E/bindView(3192): Called: 82
06-11 21:50:14.695: E/newView(3192): Called: 83
06-11 21:50:14.695: E/bindView(3192): Called: 83
06-11 21:50:14.750: E/bindView(3192): Called: 84
06-11 21:50:14.750: E/bindView(3192): Called: 85
06-11 21:50:14.757: E/bindView(3192): Called: 86
06-11 21:50:14.757: E/bindView(3192): Called: 87
06-11 21:50:14.765: E/bindView(3192): Called: 88
06-11 21:50:14.765: E/bindView(3192): Called: 89
06-11 21:50:14.812: E/bindView(3192): Called: 90
06-11 21:50:14.820: E/bindView(3192): Called: 91
06-11 21:50:14.820: E/bindView(3192): Called: 92
06-11 21:50:14.828: E/bindView(3192): Called: 93
06-11 21:50:14.828: E/bindView(3192): Called: 94
06-11 21:50:14.828: E/bindView(3192): Called: 95
06-11 21:50:14.851: D/dalvikvm(3192): GC_CONCURRENT freed 1350K, 7% free 20078K/21511K, paused 2ms+3ms
06-11 21:50:14.882: E/bindView(3192): Called: 96
06-11 21:50:14.890: E/bindView(3192): Called: 97
06-11 21:50:14.890: E/bindView(3192): Called: 98
06-11 21:50:14.890: E/bindView(3192): Called: 99
06-11 21:50:14.898: E/bindView(3192): Called: 100
06-11 21:50:14.898: E/bindView(3192): Called: 101
06-11 21:50:14.945: E/bindView(3192): Called: 102
06-11 21:50:14.945: E/bindView(3192): Called: 103
06-11 21:50:14.953: E/bindView(3192): Called: 104
06-11 21:50:14.953: E/bindView(3192): Called: 105
06-11 21:50:14.961: E/bindView(3192): Called: 106
06-11 21:50:14.961: E/bindView(3192): Called: 107
06-11 21:50:15.078: E/bindView(3192): Called: 108
06-11 21:50:15.086: E/bindView(3192): Called: 109
06-11 21:50:15.086: E/bindView(3192): Called: 110
06-11 21:50:15.093: E/bindView(3192): Called: 111
06-11 21:50:15.093: E/bindView(3192): Called: 112
06-11 21:50:15.101: E/bindView(3192): Called: 113
06-11 21:50:15.711: E/bindView(3192): Called: 114
06-11 21:50:15.718: E/bindView(3192): Called: 115
06-11 21:50:15.718: E/bindView(3192): Called: 116
06-11 21:50:15.726: E/bindView(3192): Called: 117
06-11 21:50:15.726: E/bindView(3192): Called: 118
06-11 21:50:15.734: E/bindView(3192): Called: 119
06-11 21:50:15.734: E/bindView(3192): Called: 120
06-11 21:50:15.742: E/bindView(3192): Called: 121
06-11 21:50:15.742: E/bindView(3192): Called: 122
06-11 21:50:15.750: E/bindView(3192): Called: 123
06-11 21:50:15.750: E/bindView(3192): Called: 124
06-11 21:50:15.757: E/bindView(3192): Called: 125
06-11 21:50:15.867: E/bindView(3192): Called: 126
06-11 21:50:15.867: E/bindView(3192): Called: 127
06-11 21:50:15.875: E/bindView(3192): Called: 128
06-11 21:50:15.875: E/bindView(3192): Called: 129
06-11 21:50:15.882: E/bindView(3192): Called: 130
06-11 21:50:15.882: E/bindView(3192): Called: 131
06-11 21:50:15.922: E/bindView(3192): Called: 132
06-11 21:50:15.929: E/bindView(3192): Called: 133
06-11 21:50:15.929: E/bindView(3192): Called: 134
06-11 21:50:15.953: E/bindView(3192): Called: 135
06-11 21:50:15.961: E/bindView(3192): Called: 136
06-11 21:50:15.961: E/bindView(3192): Called: 137
06-11 21:50:15.968: D/dalvikvm(3192): GC_CONCURRENT freed 2012K, 10% free 20197K/22215K, paused 2ms+3ms
06-11 21:50:15.968: E/bindView(3192): Called: 138
06-11 21:50:15.976: E/bindView(3192): Called: 139
06-11 21:50:15.984: E/bindView(3192): Called: 140
06-11 21:50:15.984: E/bindView(3192): Called: 141
06-11 21:50:15.992: E/bindView(3192): Called: 142
06-11 21:50:15.992: E/bindView(3192): Called: 143
06-11 21:50:16.039: E/bindView(3192): Called: 144
06-11 21:50:16.039: E/bindView(3192): Called: 145
06-11 21:50:16.047: E/bindView(3192): Called: 146
06-11 21:50:16.047: E/bindView(3192): Called: 147
06-11 21:50:16.054: E/bindView(3192): Called: 148
06-11 21:50:16.054: E/bindView(3192): Called: 149
06-11 21:50:16.062: E/bindView(3192): Called: 150
06-11 21:50:16.062: E/bindView(3192): Called: 151
06-11 21:50:16.062: E/bindView(3192): Called: 152
06-11 21:50:16.070: E/bindView(3192): Called: 153
06-11 21:50:16.070: E/bindView(3192): Called: 154
06-11 21:50:16.070: E/bindView(3192): Called: 155
06-11 21:50:16.117: E/bindView(3192): Called: 156
06-11 21:50:16.117: E/bindView(3192): Called: 157
06-11 21:50:16.125: E/bindView(3192): Called: 158
06-11 21:50:16.125: E/bindView(3192): Called: 159
06-11 21:50:16.125: E/bindView(3192): Called: 160
06-11 21:50:16.132: E/bindView(3192): Called: 161
06-11 21:50:16.172: E/bindView(3192): Called: 162
06-11 21:50:16.172: E/bindView(3192): Called: 163
06-11 21:50:16.179: E/bindView(3192): Called: 164
06-11 21:50:16.179: E/bindView(3192): Called: 165
06-11 21:50:16.187: E/bindView(3192): Called: 166
06-11 21:50:16.187: E/bindView(3192): Called: 167
06-11 21:50:16.328: E/bindView(3192): Called: 168
06-11 21:50:16.336: E/bindView(3192): Called: 169
06-11 21:50:16.336: E/bindView(3192): Called: 170
06-11 21:50:16.343: E/bindView(3192): Called: 171
06-11 21:50:16.343: E/bindView(3192): Called: 172
06-11 21:50:16.351: E/bindView(3192): Called: 173
06-11 21:50:16.461: E/bindView(3192): Called: 174
06-11 21:50:16.468: E/bindView(3192): Called: 175
06-11 21:50:16.492: E/bindView(3192): Called: 176
06-11 21:50:16.492: E/bindView(3192): Called: 177
这似乎很清楚地表明,一旦通过调用newView()创建了视图,bindView() 就会处理转换视图以优化内存。
(在中间调用newView()的几行只是GridView在显示一行的两个部分而不是一个整体时需要一个新行)。