【发布时间】:2009-08-26 04:07:34
【问题描述】:
我对“ViewHolder”类有疑问。我使用“ViewHolder”来改进我的列表显示语音。我认为代码没问题,但它会抛出异常 我正在将“setText”与“Cursor”中的数据一起使用。这是我的代码:
if(row==null){
LayoutInflater inflater = LayoutInflater.from(context);
row = inflater.inflate(R.layout.sbooks_row, null);
holder = new ViewHolder();
holder.id = (TextView)row.findViewById(R.id.id);
holder.title = (TextView)row.findViewById(R.id.title);
holder.icon = (ImageView)row.findViewById(R.id.icon);
row.setTag(holder);
}
else
{
holder = (ViewHolder)row.getTag();
}
holder.title.setText(cursor.getString(cursor.getColumnIndex(SBooksDbAdapter.KEY_TITLE)));
holder.id.setText(cursor.getString(cursor.getColumnIndex(SBooksDbAdapter.KEY_ROWID)));
【问题讨论】:
标签: android list android-cursor android-viewholder