I have a problem when use "ViewHolder" class. I use "ViewHolder" to improve my List display speech. I think the code is ok, but why It throw exception when "setText" with data from "Cursor". My code here:
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)));