私はとても混乱しています。私はネット上でいくつかの提案を見つけましたが、私はこのコードで実装することはできません。ここに私の問題がある。私がスクロールするたびに、リストビューの順序が狂ってしまいます。私は何をすべきか分かりません。私は本当に助けが必要です。私は本当にあなたの優しさを感謝します。ここに私のコードは次のとおりです。アンドロイドでListViewAdapterは、スクロールするとCursorAdapterの順序が狂ってしまいます
public class ListViewAdapterMeasurement extends CursorAdapter {
TextView lblContent, lblDate;
DBHelper dbHelper;
Button btnSelect;
public ListViewAdapterMeasurement(Context context, Cursor c) {
super(context, c, FLAG_REGISTER_CONTENT_OBSERVER);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view = LayoutInflater.from(context).inflate(R.layout.details_feed, parent, false);
lblContent = (TextView) view.findViewById(R.id.lblContent);
lblDate = (TextView) view.findViewById(R.id.lblDate);
return view;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
View convertView = view;
if (convertView == null)
{
LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.details_feed, null);
}
dbHelper = new DBHelper(getApplicationContext());
int intContentIndex = cursor.getColumnIndex((Tables.FeedTable.COLUMN_CONTENT));
String strContentIndex = cursor.getString(intContentIndex);
int intDateIndex = cursor.getColumnIndex((Tables.FeedTable.COLUMN_DATE));
String strDateIndex = cursor.getString(intDateIndex);
lblContent.setText(strContentIndex);
lblDate.setText(strDateIndex);
}
}
あなたのアダプタがすべてのビューのために使用されています! uiコンポーネントをメンバー変数として使用せず、bindViewメソッドで参照してください。 –
@HenningLutherは、newViewで初期化を削除してbindViewメソッドに転送する必要があることを意味しますか? newViewの –
:return LayoutInflater.from(コンテキスト).inflate(R.layout.details_feed、parent、false); in bindView: TextView lblContent =(TextView)view.findViewById(R.id.lblContent); TextView lblDate =(TextView)view.findViewById(R.id.lblDate); –