0
votes

I will try to explain.

I have a ListView with its adapter which defines the method getView (as usual) for retrieving the appearance of the cells. The final appearance of the ListView is the one shown.

enter image description here

As you can see the first arrow is rotated of 180 degrees. It has been rotated with an animation once I clicked on it. If I'd click on it again it would be rotated to the original position again. The rotation of 180 degrees is maintained with the fillAfter parameter of the animation (then it is not fixed definitively once the animation completed).

The problem is the following: when list view is scrolled and the cell with the rotated arrow is brought out and in again the cell's view is loaded again. At this point I need to rotate the arrow again. I have two ways:

  1. use arrow.setRotation(180f)
  2. use the same animation used before with the duration set to 0

Both the ways have a problem:

  1. The rotation is fixed, then when I call the method for rotating the arrow to its original position the arrow is ALREADY on its original position (because of setRotation)
  2. The rotation is not immediate, then, when the cell is brought out and in again, for an instant it points right and after a moment left

How can I solve this problem? I need to rotate the arrow before of bringing it in again but without fixing its state as rotated of 180 degrees.

1

1 Answers

0
votes

I will suggest you if you have less posibilites of items to be placed in listview then use Dynamic Linearlayouts in ScrollView instead of ListView. As ListView generates many complexities in its own layout In making custom adapter like putting edittext in listview and do some action like delete/animation on UI component of yout listItem.