电话呼叫在TextView的点击 [英] Phone Call On TextView Click
本文介绍了电话呼叫在TextView的点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何拨打电话在Android中,当用户点击的TextView然后自动众议院在TextView中一些?
TextView的电视=(TextView中)findViewById(R.id.tv_contact);
。字符串URL = tv.getText()的toString();
意向意图=新的意图(Intent.ACTION_CALL,Uri.parse(URL));
tv.setOnClickListener(新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
startActivity(意向);
}
});'
解决方案
首先通过在layout.xml添加以下让你的TextView可点击
<的TextView
...
...
机器人:可点击=真正的>
< / TextView的>
然后在你的活动课,里面那个特定的TextView的OnClickListener增加低于code
意图callIntent =新的意图(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(电话:+。+ textView.getText()的toString()修剪()));
startActivity(callIntent);
How to make a phone call in android when user Click on textView then automatically dail a number in textView ?
TextView tv=(TextView) findViewById(R.id.tv_contact);
String url = tv.getText().toString();
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
tv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(intent);
}
});'
解决方案
First make your TextView clickable by adding below in your layout.xml
<TextView
...
...
android:clickable="true">
</TextView>
Then in your Activity Class, inside OnClickListener of that particular TextView add below code
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+"+textView.getText().toString().trim()));
startActivity(callIntent );
这篇关于电话呼叫在TextView的点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文