相关疑难解决方法(0)

在ListView中为新添加的项目添加动画

如何为新添加的项目添加动画ListView

我有一个adapter,当我在列表中添加新项目时,我说adapter.notifyDataSetChanged();项目已添加,一切正常,但我的问题是我想要新添加的元素有一些动画.

animation android listview adapter

13
推荐指数
3
解决办法
3万
查看次数

在ListView中为列表项设置动画

我尝试在ListView中为新项目制作动画.我有稳定的id-s,所以我确切知道要动画的元素.问题来自ListView的循环机制.当我知道我有一个最近插入的元素时,我在视图上调用startAnimation.但随后,视图得到了回收,充满了不同的数据.它会在UI上为错误的行设置动画.在某些时候,视图持有正确的数据,但随后被回收.我通过logcat证实了这一点.有什么方法可以解决这个问题吗?

编辑:

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); …
Run Code Online (Sandbox Code Playgroud)

android listview adapter

8
推荐指数
3
解决办法
1万
查看次数

标签 统计

adapter ×2

android ×2

listview ×2

animation ×1