Android listview button and edittext

Source: Internet
Author: User

Click the button to edit all edittext of listview and display the delete button.

 
If (null! = Datalist & 0 <datalist. size () {for (INT I = 0; I <datalist. size (); I ++) {view = listview. getchildat (I); edittext edittxt((edittext=view.findviewbyid(r.id.txt _ number); button btnprice = (button) view. findviewbyid (R. id. btn_price); If (null! = Edittxt) {edittxt. setenabled (true);} If (null! = Btnprice) {btnprice. setvisibility (view. Visible );}}}

Step 2 rewrite the adapter to set the button event in getview

Holder. btdel. settag (position); holder. btdel. setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {views = V; // todo auto-generated method stubnew alertdiener. builder (context ). settitle ("prompt "). setmessage ("are you sure you want to delete it? "). Setpositivebutton ("OK", new dialoginterface. onclicklistener () {@ overridepublic void onclick (dialoginterface dialog, int which) {// todo auto-generated method stublistdata. remove (listdata. get (integer. valueof (views. gettag (). tostring (); yydatasetchanged ();}}). setnegativebutton ("cancel", new dialoginterface. onclicklistener () {@ overridepublic void onclick (dialoginterface dialog, int which) {// todo auto-generated method stubdialog. dismiss ();}}). show ();}});

Related Article

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.