开发者

Android listview containing phone number and email. want to click and make call or email

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 interf开发者_如何学Cering 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);  
        }

    });  
  } 
} 


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);
           }  
       }

});  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜