में सूची सूची एनिमेट करें मैं अपनी सूची दृश्य में नए आइटम एनिमेट करने का प्रयास करता हूं। मेरे पास स्थिर आईडी है, इसलिए मुझे पता है कि कौन सा तत्व एनिमेट करना है। समस्या ListView के रीसायकल तंत्र से आता है। जब मैं जानता हूं कि मुझे हाल ही में सम्मिलित तत्व मिला है तो मैं दृश्य पर एनीमेशन को कॉल करता हूं। लेकिन फिर, दृश्य को विभिन्न डेटा से भरा, पुनर्नवीनीकरण किया गया। यह गलत पंक्ति को एनिमेट करने वाले यूआई पर परिणाम देता है। कुछ बिंदु पर दृश्य सही डेटा धारण कर रहा था, लेकिन फिर पुनर्नवीनीकरण किया गया। मैंने लॉगकैट के माध्यम से इसकी पुष्टि की। क्या इसे हल करने का कोई तरीका है?ListView
संपादित करें:
public ExpensCursorAdapter(Context context, Cursor c, boolean autoRequery,
CopyOnWriteArraySet<String> fadeAnimateTags) {
super(context, c, autoRequery);
this.mFadeAnimTags = fadeAnimateTags;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
setup(view, context, cursor);
}
private void setup(View view, Context context, Cursor cursor) {
final String id = cursor.getString(4);
if (LOCAL_LOGV) Log.v(TAG, String.format("Create item for %s. Received view: %s", id, view.toString()));
view.setTag(id);
final TextView dateText = (TextView) view.findViewById(R.id.date);
final TextView timeText = (TextView) view.findViewById(R.id.time);
final TextView title = (TextView) view.findViewById(R.id.title);
final TextView amount = (TextView) view.findViewById(R.id.amount);
final Date date = new Date(cursor.getLong(0));
title.setText(cursor.getString(1));
dateText.setText(dFormat.format(date));
timeText.setText(tFormat.format(date));
amount.setText(String.format("%d Ft", cursor.getInt(2)));
if (cursor.getInt(3) == 1) {
timeText.setTextColor(Color.LTGRAY);
title.setTextColor(Color.LTGRAY);
dateText.setTextColor(Color.LTGRAY);
amount.setTextColor(Color.LTGRAY);
} else {
timeText.setTextColor(Color.BLACK);
title.setTextColor(Color.BLACK);
dateText.setTextColor(Color.BLACK);
amount.setTextColor(Color.BLACK);
}
if (mFadeAnimTags.contains(id)) {
view.setAnimation(AnimationUtils.loadAnimation(context, R.anim.fade));
mFadeAnimTags.remove(id);
}
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.expense_list_item, parent, false);
setup(view, context, cursor);
return view;
}
आप कहाँ एनीमेशन शुरू कर रहे हैं? मुझे लगता है कि यह एडाप्टर की getView() विधि पर होना चाहिए। – manelizzard
मैं वहां से शुरू करता हूं। प्रश्न में कोड जोड़ा गया। – gmate
क्या आपने पंक्ति को "सेटअप" करते समय हर बार नई एनिमेशन ऑब्जेक्ट बनाने का प्रयास किया है? शायद क्योंकि आप एक स्थिर विधि का उपयोग कर रहे हैं, यह हमेशा एक ही एनीमेशन का संदर्भ देता है और यह एक पंक्ति से दूसरे में बदल जाता है। – manelizzard