Android to add a click event to the TextView method _android

Source: Internet
Author: User

First set the TextView clickable property to True.

You can set it in a layout file, such as:

<textview

      android:id= "@+id/phone"

      android:clickable= "true"---------> Set this property

      Android:layout_ marginleft= "10DP"

      android:layout_below= "@id/address"

      android:layout_torightof= "@id/avatar"

      Android : layout_width= "wrap_content"

      android:layout_height= "wrap_content"

      android:layout_margintop= "10DP"

      android:text= "18764563523"

      android:textcolor= "@color/white"/>

You can also set the following in Java code:

Textview.setclickable (TRUE);

Then bind the event callback function:

Textview.setonclicklistener (New Onclicklistener () {

@Override public

void OnClick (View arg0) {

//dial-up interface

uri uri = uri.parse ("tel:18764563501");  

Intent Intent = new Intent (intent.action_dial, URI);   

StartActivity (intent);

}

);

Complete the TextView Click event Bindings!

The above is a small series for everyone to bring Android to TextView add click event to achieve the full content of the method, I hope that we support cloud-Habitat Community ~

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.