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 ~