ListView控件:prevent从回收的视图视图、控件、ListView、prevent

2023-09-05 04:01:11 作者:丧的开心

我有一个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启动动画。

怎样使用ListView控件展示数据

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.

 
精彩推荐
图片推荐