너무 혼란 스럽습니다. 내가 그물에 대한 몇 가지 제안을 발견했지만이 코드에 그것을 구현할 수 없습니다. 여기 내 문제가있다. 스크롤 할 때마다 목록보기의 순서가 엉망입니다. 나는 무엇을해야할지 모른다. 정말 도움이 필요해. 나는 너의 친절을 진심으로 감사 할 것이다. 여기에 내 코드입니다 :이다 "newView"보다 더 많은 것이 분명 once.To "의 Bindview"에서 사용할 수있는 "newView"에서 이미 인스턴스화보기를 의미스크롤하면 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 : 반환 LayoutInflater.from (컨텍스트) .inflate (R.layout.details_feed, 부모, 거짓); in bindView : TextView lblContent = (TextView) view.findViewById (R.id.lblContent); TextView lblDate = (TextView) view.findViewById (R.id.lblDate); –