在列表视图中调用intent

时间:2011-09-16 11:45:16

标签: android listview android-intent

我正在开发Android应用程序。我正在使用Web服务来检索我的应用程序中的数据。现在在我的一个功能中,我获取员工的完整细节并将其显示在列表视图中。现在在列表视图中有一些电话号码(超过2个)是他们的。现在我想使用调用意图是否有可能在列表视图中如果是,请让我知道方式。谢谢。

2 个答案:

答案 0 :(得分:0)

使用

  

onItemClickListener

listView的

并在

中调用你想要的意图
  

的onClick

方法。

答案 1 :(得分:0)

onlistitemclick you enter below code as per position.............  



                    AlertDialog.Builder alertbox = new AlertDialog.Builder(
                            Contact.this);
                    alertbox.setTitle("Calling...");
                    alertbox.setMessage("773-288-1456");

                    alertbox.setPositiveButton("Call",
                            new DialogInterface.OnClickListener() {

                                // do something when the button is clicked
                                public void onClick(DialogInterface arg0, int arg1) {
                                    Intent callIntent = new Intent(
                                            Intent.ACTION_CALL);
                                    callIntent.setData(Uri
                                            .parse("tel:773-288-1456"));
                                    startActivity(callIntent);
                                }
                            });

                    // set a negative/no button and create a listener
                    alertbox.setNegativeButton("Cancel",
                            new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface arg0, int arg1) {

                                }
                            });

                    // display box
                    alertbox.show();