Android 如何在单击ListView时打开拨号程序

Android 如何在单击ListView时打开拨号程序,android,Android,我有一个应用程序,其中列表视图在列表视图编号中,按钮在那里,我希望按钮点击编号进入拨号屏幕。。。 请建议我想您要求的是通话功能,请点击下面的代码 Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + "2356894745")); startActivity(intent); 您可以这样尝试: phone.setOnClickListener(new OnClickListener

我有一个应用程序,其中列表视图在列表视图编号中,按钮在那里,我希望按钮点击编号进入拨号屏幕。。。
请建议

我想您要求的是通话功能,请点击下面的代码

Intent intent = new Intent(Intent.ACTION_DIAL); 
intent.setData(Uri.parse("tel:" + "2356894745"));
startActivity(intent); 
您可以这样尝试:

phone.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

           Intent intent = new Intent(Intent.ACTION_DIAL); 
           intent.setData(Uri.parse("tel:" + "12345"));
           startActivity(intent); 

        }
    });
需要'tel:'前缀,否则将引发以下异常: java.lang.IllegalStateException:无法执行活动的方法

操作拨号不需要任何权限。

如果您想立即拨打该号码,您可以使用action
Intent.action\u call
。在这种情况下,必须在AndroidManifest.xml中添加以下权限:

<uses-permission android:name="android.permission.CALL_PHONE" />

公共类帮助\u活动{

@Override
public void onCreate(Bundle abc){
    //super.onCreate(savedInstanceState);

    super.onCreate(abc);
    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    HashMap<String, String> item = new HashMap<String, String>();
    HashMap<String, String> item2 = new HashMap<String, String>();
    HashMap<String, String> item3 = new HashMap<String, String>();
    HashMap<String, String> item4 = new HashMap<String, String>();
    HashMap<String, String> item5 = new HashMap<String, String>();
    HashMap<String, String> item6 = new HashMap<String, String>();
    HashMap<String, String> item7 = new HashMap<String, String>();
    HashMap<String, String> item8 = new HashMap<String, String>();
    HashMap<String, String> item9 = new HashMap<String, String>();
    HashMap<String, String> item10 = new HashMap<String, String>();

    item.put("name", "Pune Ambulance");
    item.put("number", "101");
    item.put("address", "Pune City");

    item2.put("name", "Jeevan Jyoti Services");
    item2.put("number", "02067288011");
    item2.put("address", "Nali Road, Hadapsar");

    item3.put("name", "Bharat Ambulance Services");
    item3.put("number", "02066823158");
    item3.put("address", "Hospital Vallabh Nagar, Pimpri");        

    item4.put("name", "Lokmangal Ambulance Services");
    item4.put("number", "02040422273");
    item4.put("address", "Hospital, Deccan Gymkhana");        

    item5.put("name", "Deendayal Memorial Hospital");
    item5.put("number", "02025652497");
    item5.put("address", "Paduka, Fergusson College Road");        

    item6.put("name", "Ruby Hall Clinic");
    item6.put("number", "02026121099");
    item6.put("address", "Bund Garden Road, Pune");        

    item7.put("name", "Sahyadri Hospital");
    item7.put("number", "02025403000");
    item7.put("address", "");        

    item8.put("name", "Deenanath Mangeshkar Hospital Ambulance Services");
    item8.put("number", "02040151000");
    item8.put("address", "Erandwane");        

    item9.put("name", "Jehangir Hospital");
    item9.put("number", "02026121066");
    item9.put("address", "Pune Station, Pune");    

    item10.put("name", "Kolumbus Ambulance And Healthcare");
    item10.put("number", "02066826189");
    item10.put("address", "Shirole Road, Shivaji Nagar");    

    list.add(item);
    list.add(item2);
    list.add(item3);
    list.add(item4);
    list.add(item5);
    list.add(item6);
    list.add(item7);
    list.add(item8);
    list.add(item9);
    list.add(item10);


    String[] columns = new String[] { "name", "number", "address" };
    int[] renderTo = new int[] { R.id.name, R.id.number, R.id.address };

    ListAdapter listAdapter = new SimpleAdapter(this, list,   R.layout.help_ambulance_row, columns, renderTo);

    setListAdapter(listAdapter);
}       
@覆盖
创建时的公共作废(捆绑abc){
//super.onCreate(savedInstanceState);
super.onCreate(abc);
ArrayList=新建ArrayList();
HashMap项=新建HashMap();
HashMap item2=新的HashMap();
HashMap item3=新的HashMap();
HashMap item4=新的HashMap();
HashMap item5=新的HashMap();
HashMap item6=新的HashMap();
HashMap item7=新的HashMap();
HashMap item8=新的HashMap();
HashMap item9=新的HashMap();
HashMap item10=新的HashMap();
项目名称(“名称”、“浦那救护车”);
项目.付诸表决(“编号”、“101”);
项目投入(“地址”、“浦那市”);
项目2.投入(“名称”、“吉万Jyoti服务”);
项目2.投入(“编号”,“0206728011”);
项目2.put(“地址”,“哈达帕萨纳里路”);
项目3.put(“名称”、“Bharat救护车服务”);
第3项:投入(“编号”,“02066823158”);
项目3.put(“地址”,“Pimpri Vallabh Nagar医院”);
项目4.put(“名称”、“Lokmangal救护车服务”);
第4项:投入(“编号”,“0200422273”);
项目4.put(“地址”,“医院,德干吉姆卡纳”);
项目5.填写(“名称”、“迪恩迪亚尔纪念医院”);
项目5.投入(“编号”,“02025652497”);
项目5.put(“地址”,“费尔古森学院路帕杜卡”);
项目6.填写(“名称”、“Ruby Hall诊所”);
第6项投入(“编号”,“02026121099”);
项目6.put(“地址”,“浦那外滩花园路”);
第7项:填写(“名称”、“Sahyadri医院”);
第7项投入(“编号”,“02025403000”);
项目7.将(“地址”和“);
项目8.填写(“名称”、“Deenanath Mangeshkar医院救护车服务”);
第8项投入(“编号”,“0204015000”);
第8项:填写(“地址”、“埃兰德瓦内”);
第9项:填写(“名称”、“杰汉吉尔医院”);
第9项投入(“编号”,“02026121066”);
第9项put(“地址”,“浦那站,浦那”);
第10项:填写(“名称”、“科伦巴斯救护车和医疗保健”);
第10项投入(“编号”,“02066826189”);
项目10.put(“地址”,“Shivaji Nagar Shirole路”);
列表。添加(项目);
增加(第2项);
增加(第3项);
增加(第4项);
增加(第5项);
增加(第6项);
增加(第7项);
增加(第8项);
增加(第9项);
增加(第10项);
字符串[]列=新字符串[]{“名称”、“编号”、“地址”};
int[]renderTo=newint[]{R.id.name,R.id.number,R.id.address};
ListAdapter ListAdapter=new SimpleAdapter(此,列表,R.layout.help\u行,列,renderTo);
setListAdapter(listAdapter);
}       
}