Add Delete Item animation to Android ListView

Source: Internet
Author: User

Add Delete Item animation to Android ListView

Adding a folding animation to the ListView when you delete an item will feel better.

The step is to delete a view, first using the animation to change the height of the view, it looks like a folding effect. When the animation is finished, the item is actually removed.

    private void Deletepattern (final view view, final int position) {Animation.animationlistener Al = new Animatio            N.animationlistener () {@Override public void Onanimationstart (Animation Animation) {} @Override public void Onanimationend (Animation Animation) {Mdbhelper.deletecustompatt                Ern (Mpatternlist.get (position));                Mpatternlist.remove (position);            Mpatternadapter.notifydatasetchanged ();        } @Override public void Onanimationrepeat (Animation Animation) {}};    Collapse (view, AL); private void collapse (final view view, Animation.animationlistener al) {final int originheight = View.getmeas        Uredheight (); Animation Animation = new Animation () {@Override protected void applytransformation (float Interpola         Tedtime, transformation t) {if (Interpolatedtime = = 1.0f) {           View.setvisibility (View.gone);                    } else {view.getlayoutparams (). Height = originheight-(int) (originheight * interpolatedtime);                View.requestlayout ();            }} @Override public boolean willchangebounds () {return true;        }        };        if (Al! = null) {Animation.setanimationlistener (AL);        } animation.setduration (300);    View.startanimation (animation); }

Add Delete Item animation to Android ListView

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.