Android 列表视图包含电话号码和电子邮件。想要点击并拨打电话或发送电子邮件

发布于 2024-11-19 14:32:25 字数 1635 浏览 4 评论 0原文

正如我的标题中所述,我的列表视图中只有 2 个对象。我想拿一个打电话,然后在单击时将另一个与电子邮件应用程序一起使用。我已经实现了调用功能,但是测试时,它只是调用一串随机数字。为什么?

如何在不干扰电话功能的情况下拨打电子邮件功能并将电子邮件(详细信息)粘贴到发件人空白处?

import android.app.ListActivity; 
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.ArrayAdapter; 
import android.widget.EditText;
import android.widget.ListView; 
import android.widget.TextView; 
import android.widget.Toast; 
import android.widget.AdapterView.OnItemClickListener; 

public class Viewer extends ListActivity { 

  static String[] DETAILS;
  static String[] PHONE;

  public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    super.onCreate(savedInstanceState);
    Bundle b = getIntent().getExtras();
    final String name = b.getString("name");
    Bundle a = getIntent().getExtras();
    final String number = a.getString("number"); 

    DETAILS = new String[] {name, number};
    PHONE = new String[] {number};

    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, DETAILS));
    ListView lv = getListView(); 
    lv.setTextFilterEnabled(true); 


    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
        public void onItemClick(AdapterView parentView, View childView, int position, long id) {  
               Intent sIntent = 
                    new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + PHONE));
               startActivity(sIntent);  
        }

    });  
  } 
} 

as described in my title, I have 2 objects only in my listview. I want to take one and call and use the other with an email app when clicked. I have implemented the call function, but when tested, it just calls a random string of numbers. Why?

And how do I make a call on an email function and paste the email (DETAILS) to the sender blank without interfering with the phone function?

import android.app.ListActivity; 
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.ArrayAdapter; 
import android.widget.EditText;
import android.widget.ListView; 
import android.widget.TextView; 
import android.widget.Toast; 
import android.widget.AdapterView.OnItemClickListener; 

public class Viewer extends ListActivity { 

  static String[] DETAILS;
  static String[] PHONE;

  public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    super.onCreate(savedInstanceState);
    Bundle b = getIntent().getExtras();
    final String name = b.getString("name");
    Bundle a = getIntent().getExtras();
    final String number = a.getString("number"); 

    DETAILS = new String[] {name, number};
    PHONE = new String[] {number};

    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, DETAILS));
    ListView lv = getListView(); 
    lv.setTextFilterEnabled(true); 


    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
        public void onItemClick(AdapterView parentView, View childView, int position, long id) {  
               Intent sIntent = 
                    new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + PHONE));
               startActivity(sIntent);  
        }

    });  
  } 
} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉薄对峙 2024-11-26 14:32:25
Intent sIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + PHONE[0]));

如果仅收听电话,请点击:

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
       public void onItemClick(AdapterView parentView, View childView, int position, long id) {  
           if (1 == position) {
               Intent sIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + DETAILS[position]));
               startActivity(sIntent);
           }  
       }

});  
Intent sIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + PHONE[0]));

For listening only phones click:

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
       public void onItemClick(AdapterView parentView, View childView, int position, long id) {  
           if (1 == position) {
               Intent sIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + DETAILS[position]));
               startActivity(sIntent);
           }  
       }

});  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文