当前位置: 动力学知识库 > 问答 > 编程问答 >

android - LayoutAnimationController in order to display one by one element of list

问题描述:

So I'm facing this problem:

I need to display a list of item loaded asynchronously.

When they are loaded, I want to display them one by one. I try to use the LayoutAnimationController. But it seems that it has issues and i can't understand what it is.

Here is my code :

 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() {

}

});

I tried to set the adapter inside the OnSuccess callback, but the result is the same.

And strangely, when using the instant run from Android Studio, I have the expected result. But when refreshing the whole app, i see no animations

分享给朋友:
您可能感兴趣的文章:
随机阅读: