从contactlist机器人比赛接触 [英] android match contact from contactlist

查看:163
本文介绍了从contactlist机器人比赛接触的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也试试这个code..it工作正常。

I have try this code..it is working fine..

public class Test extends Activity implements OnItemClickListener{

List<String> name1 = new ArrayList<String>();
List<String> name2 = new ArrayList<String>();
List<String> phno1 = new ArrayList<String>();
List<String> matchedList;
MyAdapter ma ;
Button select;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    name2.add("Abc");
    name2.add("Xyz");
    name2.add("Pqr");
    name2.add("aaa");

    getAllContacts(this.getContentResolver());

    ListView lv= (ListView) findViewById(R.id.lv);
    ma = new MyAdapter();
    lv.setAdapter(ma);
    lv.setOnItemClickListener(this); 
    lv.setItemsCanFocus(false);
    lv.setTextFilterEnabled(true);



}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub

}

public  void getAllContacts(ContentResolver cr) {
    Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
    while (phones.moveToNext())
    {
        String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY));
        String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
        System.out.println(".................."+phoneNumber); 
        name1.add(name);
        phno1.add(phoneNumber);



    }

    phones.close();
}
class MyAdapter extends BaseAdapter 
{ 

    LayoutInflater mInflater;
    TextView tv1,tv;

    MyAdapter()
    {
        // mCheckStates = new SparseBooleanArray(name1.size());
        mInflater = (LayoutInflater)Test.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return name1.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub

        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        View vi=convertView;
        if(convertView==null)
            vi = mInflater.inflate(R.layout.row_list, null); 
        TextView tv= (TextView) vi.findViewById(R.id.txt_name);
        tv1= (TextView) vi.findViewById(R.id.txt_phoneNo);

        tv.setText("Name :"+ name1.get(position));
        // tv1.setText("Phone No :"+ phno1.get(position));


        return vi;
    }

}  
  }

现在的ArrayList中NAME1我有我的设备的所有名称的列表..
和NAME2我有person..Now我想同时匹配在此列表数组列表和显示名称为present的一些selcected ArrayList中....
我工作的这一点,因为在这里的最后week..stuck。请帮我...
谢谢...:)

Now in ArrayList name1 I am having list of all name of my device.. and in name2 i am having Arraylist of some selcected person..Now i want to match both of this array list and display name in list that is present.... I am working on this since last week..stuck here .. Please help me... Thanks ...:)

推荐答案

我解决我的问题。通过闯民宅此链接..的 https://thenewcircle.com/s/post/1375/android_content_provider_tutorialHope 这将有助于别人

I solve my issue.. by refering this link..https://thenewcircle.com/s/post/1375/android_content_provider_tutorialHope this will help to someone

这篇关于从contactlist机器人比赛接触的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆