如我的标题所述,我的listview中只有2个对象。我想拿一个并在点击时使用电子邮件应用程序调用另一个。我已经实现了调用函数,但是在测试时,它只是调用随机数字串。为什么呢?
如何在电子邮件功能上拨打电话并将电子邮件(DETAILS)粘贴到发件人空白而不会干扰电话功能?
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);
}
});
}
}
答案 0 :(得分:1)
Intent sIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + PHONE[0]));
仅限收听phones
点击:
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);
}
}
});