Android Imitation iphone ListView Drag Sort button linkage Delete Show hidden

Source: Internet
Author: User
Tags gety

You need to modify the ListView class override Onintercepttouchevent () and ontouchevent ()//experiment with another method, overwriting the ontouchevent () of the drag icon in each row of the ListView, but the effect is not ideal. public class Mainactivity extends Activity {deleteadapter Deleteadapter;draglistview listview;boolean bflag;i Magebutton button; @Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main);d eleteadapter = new Deleteadapter (this, getData ()); ListView = (Draglistview) Findviewbyid (R.id.listview1); Listview.setadapter (deleteadapter); button = (ImageButton) Findviewbyid ( R.id.imagebutton1) Bflag = False;button.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View ARG0) {//TODO auto-generated method stubif (!bflag) {deleteadapter.imgvisibility = true;button.setpressed (true); BFlag = True;deleteadapter.notifydatasetchanged (); Listview.setselector (Android. r.color.transparent);} else {deleteadapter.imgvisibility = false;deleteadapter.imgvisible = new Boolean[deleteadapter.getcount ()]; Button.setpresseD (false); bflag = False;deleteadapter.notifydatasetchanged (); Listview.setselector (Android. R.drawable.list_selector_background);}}); Listview.setonitemclicklistener (New Onitemclicklistener () {@Overridepublic void Onitemclick (adapterview<?> arg0, View arg1, int arg2,long arg3) {//TODO auto-generated method stubif (bflag) {if (deleteadapter.imgdvisible) {Delete adapter.imgdvisible = false;deleteadapter.imgvisible = new Boolean[deleteadapter.getcount ()]; Deleteadapter.notifydatasetchanged ();}}});} Private list

Android Imitation iphone ListView Drag Sort button linkage Delete Show hidden

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.