ListView控件:prevent从回收的视图 [英] ListView: Prevent a view from recycling

查看:494
本文介绍了ListView控件:prevent从回收的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView至极使用回收的观点。我试图prevent从回收的视图。 所以我用setHasTransientState:

  

android.support.v4.view.ViewCompatJB.setHasTransientState(查看视图,布尔hasTransientState)

它工作得非常好杰利贝恩版本,但它不能在空气污染指数与其中做任何事情; 16。 有没有一种方法,使其工作或者有不同的方法pre杰利贝恩?


我发现了如何设置RecyclerListener例如 @Daniel周星驰建议。

  listView.setRecyclerListener(新RecyclerListener(){
        @覆盖
        公共无效onMovedToScrapHeap(查看视图){
            //停止动画了这一观点
        }
});
 

解决方案

有关pre杰利贝恩,我想你可以只使用setRecyclerListener的ListView和时RecyclerListener#onMovedToScrapHeap(查看视图)被调用,清除的动画查看谁已被回收,直接做本该是最后的工作,当动画结束工作要做。

里面onMovedToScrapHeap(查看视图)$ C $,c取决于你如何实现动画,如你可以调用查看#clearAnimation(),如果你previously用于查看#startAnimation启动动画。

I have a ListView wich use recycled views. I'm trying to prevent a view from recycle. So I use setHasTransientState:

android.support.v4.view.ViewCompatJB.setHasTransientState(View view, boolean hasTransientState)

It works very well on Jellybean version but it doesn't do anything on Api < 16. Is there a way to make it work or there is different approach for pre Jellybean ?


I found out how to set a RecyclerListener like @Daniel Chow suggested.

listView.setRecyclerListener(new RecyclerListener() {
        @Override
        public void onMovedToScrapHeap(View view) {
            // Stop animation on this view
        }
});

解决方案

For pre Jellybean, I think you can just use setRecyclerListener on ListView and when RecyclerListener#onMovedToScrapHeap(View view) is called, clear the animation on the view who has been recycled and directly do the final job which was supposed to be done when animation ends.

The code inside onMovedToScrapHeap(View view) depends on how you implement the animation, e.g. you can call View#clearAnimation() if you previously used View#startAnimation to start animation.

这篇关于ListView控件:prevent从回收的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆