2017-02-22 155 views
0

所以我面临这个问题: 我需要显示异步加载的项目列表。 当他们被加载时,我想逐一显示它们。我尝试使用LayoutAnimationController。但它似乎有问题,我不明白它是什么。LayoutAnimationController为了显示列表中的一个一个的元素

这里是我的代码:

this.adapter = new ReactionTypeAdapter(getActivity(), R.layout.row_reaction_type, reactionTypeArrayList); // reactionTypeArrayList at this stage. 
    reactionTypeListView.setAdapter(adapter); 

    Animation animation = new AlphaAnimation(1.0f, 0.0f); // these are de debug parameters in order to see if the animation play 
    animation.setDuration(500); 
    final LayoutAnimationController controller = new LayoutAnimationController(animation, 0.5f); 
    controller.setOrder(LayoutAnimationController.ORDER_NORMAL); 
    reactionTypeListView.setLayoutAnimation(controller); 

    reactionTypeRepository.retrieveAll(new IRepositoryCallback<ArrayList<ReactionType>>() { 
     @Override 
     public void OnSuccess(ArrayList<ReactionType> entity) { 
      adapter.addAll(entity); 
      adapter.notifyDataSetChanged(); 
     } 

     @Override 
     public void OnError() { 

     } 
    }); 

我试图设置的onSuccess回调里面的适配器,但结果是一样的。

奇怪的是,当使用Android Studio的即时运行时,我得到了预期的结果。但刷新整个应用程序时,我看不到动画

回答

相关问题