【问题标题】:Calling intent in the list view在列表视图中调用意图
【发布时间】:2011-09-16 11:45:15
【问题描述】:

我正在开发安卓应用程序。我正在使用 Web 服务来检索我的应用程序中的数据。现在在我的一个功能中,我获取员工的全部详细信息并将其显示在列表视图中。现在在列表视图中有某些电话号码(超过 2 个)是他们的。现在我想使用呼叫意图是否可以在列表视图中如果是的话让我知道方式。谢谢。

【问题讨论】:

    标签: android listview android-intent


    【解决方案1】:
    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();
    

    【讨论】:

    • 但我在列表视图中有多个号码。一名员工有多个号码。
    • 我使用了 4 行,其中 3 行显示数字。
    • 你在listview中的第一行位置为零,使用switch语句你可以获得每一行的值......
    【解决方案2】:

    使用

    onItemClickListener

    listView 中并调用你想要的intent

    点击

    它的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-10
      • 1970-01-01
      相关资源
      最近更新 更多