I have some TextViews for phone no. These are not editable. So I have made them as TextView. I want to perform click action on phone no, i.e开发者_StackOverflow中文版. on clicking phone no i have to make a call. How to implement that? Anyone any idea?
The best way to get that functionality is to set this parameter for your TextView in which you display the phone number:
android:autoLink="phone"
Alternatively (not sure if this is a good practice though. perhaps someone could help out here), you can set it to
android:autoLink="all"
The later will detect any email addresses, website URL's, maps and convert them into relevant links on the fly.
add ClickListener to that textview
textview.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String number = "tel:"+youPhoneNo;
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
startActivity(Intent.createChooser(callIntent, "Phone..."));
}
});
精彩评论