Ich versuche nur, Animation für "add" -Methode in Listview zu erstellen. Dies funktioniert sehr gut, aber die Animation wird auch ausgelöst, indem Sie den Artikel aus der Listenansicht entfernen.ListView - Animation beim Hinzufügen neuer Zeile
So
insert to index 0 -> "item 1" -> animation
insert to index 0 -> "item 2" -> animation
insert to index 0 -> "item 3" -> animation
Ergebnis
item 3
item 2
item 1
und jetzt will ich "Punkt 1" zum Beispiel entfernen ... und Animation ist natürlich ausgelöst auf dem Index 0 (Punkt 3 -> Start Animation)
Woher weiß ich, dass dies eine Entfernungsmethode ist?
private static void blink(final View v)
{
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(300);
animation.setStartOffset(20);
animation.setRepeatMode(Animation.REVERSE);
animation.setRepeatCount(Animation.INFINITE);
v.setAnimation(animation);
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
v.setAnimation(null);
}
}).start();
}
Adapter
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent)
{
LayoutInflater inflater = LayoutInflater.from(getContext());
View view = inflater.inflate(R.layout.alert_custom_row, parent, false);
if(position == 0) // HERE some like isNewRow()?
blink(view);
return view;
}
Aktivität
adapter.insert("item", 0);
adapter.notifyDataSetChanged();
Vielen Dank für mich zu helfen.