Eatwhatapp Development Combat (13)

Source: Internet
Author: User

This time, we modify the edittext of the item to add the store name, and let the Add button change with the content of EditText. The code above is the first modification of the two controls on the XML file:
<relativelayout         android:id= "@+id/et_relative"        android:layout_width= "Match_parent"        android: layout_height= "Wrap_content" >        <edittext     android:id= "@+id/addshop_et"    android:layout_width= " Match_parent "    android:layout_height=" wrap_content "    android:textsize=" 18sp "    android:hint=" shop name "/> <textview     android:id= "@+id/add_shop_text"    android:layout_width= "wrap_content"    android:layout_ height= "Wrap_content"    android:layout_alignparentright= "true"    android:focusable= "true"    android:o nclick= "Addshop"    android:textsize= "18sp"    android:layout_marginright= "5dip"    android:layout_ margintop= "5dip"    android:text= "@string/add_shop_btn_text"    android:visibility= "Gone"/>    </ Relativelayout>
Next define and initialize the corresponding control:
Private TextView add_shop_text;//Initialization control Add_textadd_shop_text = (TextView) Findviewbyid (r.id.add_shop_text);// Initialize control Addshop_edittextaddshop_et = (EditText) Findviewbyid (r.id.addshop_et);//edittext Set Listener Addshop_ Et.addtextchangedlistener (New TextChanged ());
Set the modified text content of EditText monitor addtextchangedlistener ();
    Class TextChanged implements textwatcher{@Overridepublic void beforetextchanged (charsequence s, int start, int count,int After) {//TODO auto-generated method stub} @Overridepublic void OnTextChanged (charsequence s, int start, int before,int Co UNT) {//TODO auto-generated method stub} @Overridepublic void Aftertextchanged (Editable s) {}}
InaftertextchangedWrite the corresponding logic in the (Editable s) method:
if (s! = null &&! "".  Equals (S.tostring ())) {add_shop_text.setvisibility (view.visible);  }else {add_shop_text.setvisibility (view.invisible); }
This completes the function, which appears when the text box has content input.

Eatwhatapp Development Combat (13)

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.