Android - animation when removing items from a list

I have a ListView in action. Each list item has text and a CheckBox. When you click on CheckBox, I want to remove an item from the ListView and want to add an animation, for example, slide down or disappear, and then delete.

Any help?

+7
source share
2 answers

Look at my answer

protected void removeListItem(View rowView, final int positon) { // TODO Auto-generated method stub final Animation animation = AnimationUtils.loadAnimation(rowView.getContext(), R.anim.splashfadeout); rowView.startAnimation(animation); Handler handle = new Handler(); handle.postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub array.remove(positon); adapter.notifyDataSetChanged(); animation.cancel(); } }, 1000); } 

call removeListItem(View rowView, final int positon) method removeListItem(View rowView, final int positon) in onItem click ListView

 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView <? > parent, View rowView, int positon, long id) { // TODO Auto-generated method stub Toast.makeText(rowView.getContext(), "" + positon, Toast.LENGTH_LONG).show(); removeListItem(rowView, positon); } }); 

and res / anim / splashfadeout.xml

  <?xml version="1.0" encoding="utf-8" ?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator" android:zAdjustment="top" android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="2000" /> 

The full source code of the animated ListView hear

+6
source

You must implement onClickListener on the checkbox in the ur adapter class and set the visibility of the text GONE or Invisible there or remove the element from the ur list and call the notifyDataSetChanged () method ....

-one
source

All Articles