Android 列表视图包含电话号码和电子邮件。想要点击并拨打电话或发送电子邮件
正如我的标题中所述,我的列表视图中只有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果仅收听
电话
,请点击:For listening only
phones
click: