我的列表视图有问题,数据工作正常,但是当我向下滚动它时,标题不断重复,但我点击它时的内容正在工作。
这是模拟器中的图像。
这是我数据库中的数据
这是我在列表视图中使用的代码
dataset_cursor = helper.getBooksByTitle2();
startManagingCursor(dataset_cursor);
adapter = new ContentAdapter(dataset_cursor);
list.setAdapter(adapter);`
class ContentAdapter extends CursorAdapter{
ContentAdapter(Cursor c)
{
super(LEGALe.this, c);
}
public void bindView(View row, Context ctxt, Cursor c)
{
ContentHolder holder = (ContentHolder)row.getTag();
holder.populateFrom(c, helper);
}
public View newView (Context ctxt, Cursor c, ViewGroup parent)
{
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.row2, parent, false);
ContentHolder holder = new ContentHolder(row);
row.setTag(holder);
return(row);
}
}
public Cursor getBooksByTitle2()
{
return (getReadableDatabase().rawQuery("SELECT _id,table_of_content FROM tblContent WHERE title_id='"+ LEGALe.passedVar.toString() +"' ORDER BY table_of_content" , null));
}