从通讯录中导入联系人并去重

来源:互联网 发布:广西广电网络多少钱 编辑:程序博客网 时间:2024/06/05 09:14

首先给出实现完的界面图




上面是给出来的实现结果图。

从本地联系人中导出联系人,需要使用ContentProvider来获取通讯录中的联系人。

从通讯录中获取联系人方法如下:

[java] view plain copy
  1. /** 得到手机通讯录联系人信息 **/  
  2.     private void getPhoneContacts() {  
  3.   
  4.         ContentResolver resolver = ContactsActivity.this.getContentResolver();  
  5.   
  6.         // 获取手机联系人  
  7.         Cursor cursor = resolver.query(ContactsContract.Contacts.CONTENT_URI,  
  8.                 nullnullnullnull);  
  9.   
  10.         if (cursor != null) {  
  11.             while (cursor.moveToNext()) {  
  12.                 // 查看联系人有多少个号码,如果没有号码,返回0  
  13.                 int idColumn = cursor  
  14.                         .getColumnIndex(ContactsContract.Contacts._ID);  
  15.                 int phoneCount = cursor  
  16.                         .getInt(cursor  
  17.                                 .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));  
  18.                 int displayNameColumn = cursor  
  19.                         .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);  
  20.                 // 得到联系人名称  
  21.                 String contactName = cursor.getString(displayNameColumn);  
  22.   
  23.                 // 获得联系人的ID  
  24.                 String contactId = cursor.getString(idColumn);  
  25.                 List<String> list = new ArrayList<String>();  
  26.                 if (phoneCount > 0) {  
  27.                     // 获得联系人的电话号码列表  
  28.                     Cursor phoneCursor = getContentResolver().query(  
  29.                             ContactsContract.CommonDataKinds.Phone.CONTENT_URI,  
  30.                             null,  
  31.                             ContactsContract.CommonDataKinds.Phone.CONTACT_ID  
  32.                                     + "=" + contactId, nullnull);  
  33.                     if (phoneCursor.moveToFirst()) {  
  34.                         do {  
  35.                             // 遍历所有的联系人下面所有的电话号码  
  36.                             String phoneNumber = phoneCursor  
  37.                                     .getString(phoneCursor  
  38.                                             .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));  
  39.                             // 去掉手机号中的空格和“-”  
  40.                             phoneNumber = phoneNumber.replace(" """)  
  41.                                     .replace("-""").replace("+86""");  
  42.                             if (DataTools.isMobileNO(phoneNumber)) {  
  43.                                 if (!list.contains(phoneNumber)) {  
  44.                                     list.add(phoneNumber);  
  45.                                 }  
  46.                             }  
  47.   
  48.                         } while (phoneCursor.moveToNext());  
  49.                     }  
  50.                     phoneCursor.close();  
  51.                 }  
  52.                 // //得到手机号码  
  53.                 // String phoneNumber = cursor.getString(PHONES_NUMBER_INDEX);  
  54.                 // 当手机号码为空的或者为空字段 跳过当前循环  
  55.                 if (list.size() > 0) {  
  56.                     if (!maps.containsKey(contactId)) {// 所有联系人放到maps中,  
  57.                         ContactBean bean = new ContactBean();  
  58.                         bean.setContactName(contactName);  
  59.                         bean.setContactNum(list);  
  60.                         bean.setCheck(false);  
  61.                         maps.put(contactId, bean);  
  62.                     }  
  63.                 }  
  64.             }  
  65.   
  66.             cursor.close();  
  67.         }  
  68.         if (maps.size() > 0) {// 有数据  
  69.             handler.sendEmptyMessage(1);  
  70.         } else {  
  71.             handler.sendEmptyMessage(0);  
  72.         }  
  73.     }  
实体ContactBean类

[java] view plain copy
  1. public class ContactBean implements Serializable {  
  2.     /** 
  3.      *  
  4.      */  
  5.     private static final long serialVersionUID = 1L;  
  6.     private String contactName;  
  7.     private List<String> contactNum;  
  8.     private boolean isCheck;  
  9.     private int positon = -1;  
  10.   
  11.     private String addr;  
  12.   
  13.     public String getContactName() {  
  14.         return contactName;  
  15.     }  
  16.   
  17.     public void setContactName(String contactName) {  
  18.         this.contactName = contactName;  
  19.     }  
  20.   
  21.     public List<String> getContactNum() {  
  22.         return contactNum;  
  23.     }  
  24.   
  25.     public void setContactNum(List<String> contactNum) {  
  26.         this.contactNum = contactNum;  
  27.     }  
  28.   
  29.     public boolean isCheck() {  
  30.         return isCheck;  
  31.     }  
  32.   
  33.     public void setCheck(boolean isCheck) {  
  34.         this.isCheck = isCheck;  
  35.     }  
  36.   
  37.     public int getPositon() {  
  38.         return positon;  
  39.     }  
  40.   
  41.     public void setPositon(int positon) {  
  42.         this.positon = positon;  
  43.     }  
  44.   
  45.     public String getAddr() {  
  46.         return addr;  
  47.     }  
  48.   
  49.     public void setAddr(String addr) {  
  50.         this.addr = addr;  
  51.     }  
  52.   
  53. }  


存储数据的几个对象:
// 联系人一对一
private HashMap<String, ContactBean> maps = new HashMap<String, ContactBean>();
// 联系人姓名对号码一对多
private HashMap<String, ContactBean> nameMaps = new HashMap<String, ContactBean>();
// 联系人号码对姓名一对多
private HashMap<String, ContactBean> phoneMaps = new HashMap<String, ContactBean>();
private HashSet<String> set = new HashSet<String>();

处理数据分类的方法代码如下:

[java] view plain copy
  1. public void dataClassify {  
  2.         for (Map.Entry<String, ContactBean> entry : maps.entrySet()) {// 遍历全部数据  
  3.             if (entry.getValue().getContactNum().size() > 1) {  
  4.                 nameMaps.put(entry.getKey(), entry.getValue());// 将姓名号码一对多的放入nameMaps中  
  5.             } else {  
  6.                 for (Map.Entry<String, ContactBean> entry1 : maps.entrySet()) {  
  7.                     if (!entry.getValue().getContactName()  
  8.                             .equals(entry1.getValue().getContactName())  
  9.                             && entry.getValue()  
  10.                                     .getContactNum()  
  11.                                     .get(0)  
  12.                                     .equals(entry1.getValue().getContactNum()  
  13.                                             .get(0))) {  
  14.                         // 将号码与姓名一对多的放入phoneMaps中  
  15.                         phoneMaps.put(entry.getKey(), entry.getValue());  
  16.                         phoneMaps.put(entry1.getKey(), entry1.getValue());  
  17.                     }  
  18.                 }  
  19.   
  20.             }  
  21.   
  22.         }  
  23.         for (Map.Entry<String, ContactBean> entry : nameMaps.entrySet()) {// 踢掉姓名号码一对多对象  
  24.             maps.remove(entry.getKey());  
  25.             nameList.add(entry.getValue());  
  26.         }  
  27.         for (Map.Entry<String, ContactBean> entry : phoneMaps.entrySet()) {// 踢掉号码姓名一对多对象  
  28.             maps.remove(entry.getKey());  
  29.             set.add(entry.getValue().getContactNum().get(0));  
  30.   
  31.         }  
  32.         for (String str : set) {  
  33.             List<String> list = new ArrayList<String>();  
  34.             for (Map.Entry<String, ContactBean> entry : phoneMaps.entrySet()) {  
  35.   
  36.                 if (str.equals(entry.getValue().getContactNum().get(0))) {  
  37.                     list.add(entry.getValue().getContactName());  
  38.   
  39.                 }  
  40.             }  
  41.             ContactBean contactBean = new ContactBean();  
  42.             contactBean.setContactName(str);  
  43.             contactBean.setContactNum(list);  
  44.             phoneList.add(contactBean);  
  45.         }  
  46.         for (Map.Entry<String, ContactBean> entry : maps.entrySet()) {// 放到数据集中进行适配  
  47.             dataList.add(entry.getValue());  
  48.         }  
  49.         // List<ContactBean> duList = new ArrayList<ContactBean>();  
  50.         for (int i = 0; i < dataList.size() - 1; i++) {// 去掉同名同电话数据  
  51.             for (int j = dataList.size() - 1; j > i; j--) {  
  52.                 if (dataList.get(j).getContactName()  
  53.                         .equals(dataList.get(i).getContactName())  
  54.                         && dataList.get(j).getContactNum().get(0)  
  55.                                 .equals(dataList.get(i).getContactNum().get(0))) {  
  56.                     dataList.remove(j);  
  57.                 }  
  58.             }  
  59.         }  
  60.   
  61.         adapter.notifyDataSetChanged();  
  62.     }  

一对一联系人的列表适配类ContactListAdapter

[java] view plain copy
  1. public class ContactListAdapter extends BaseAdapter {  
  2.   
  3.     private Context mContext;  
  4.     private List<ContactBean> dataList;  
  5.     private TextView numTextView;  
  6.     public ContactListAdapter(Context context, List<ContactBean> list,TextView numTextView) {  
  7.         this.mContext = context;  
  8.         this.dataList = list;  
  9.         this.numTextView = numTextView;  
  10.     }  
  11.   
  12.     @Override  
  13.     public int getCount() {  
  14.         // TODO Auto-generated method stub  
  15.         return dataList != null ? dataList.size() : 0;  
  16.     }  
  17.   
  18.     @Override  
  19.     public Object getItem(int position) {  
  20.         // TODO Auto-generated method stub  
  21.         return position;  
  22.     }  
  23.   
  24.     @Override  
  25.     public long getItemId(int position) {  
  26.         // TODO Auto-generated method stub  
  27.         return position;  
  28.     }  
  29.   
  30.     @Override  
  31.     public View getView(int position, View convertView, ViewGroup parent) {  
  32.         final int pos = position;  
  33.         final ViewHolder viewHolder;  
  34.         if (convertView == null) {  
  35.             viewHolder = new ViewHolder();  
  36.             convertView = LayoutInflater.from(mContext).inflate(  
  37.                     R.layout.item_contact_import_listview, null);  
  38.             viewHolder.nameTextView = (TextView) convertView  
  39.                     .findViewById(R.id.contact_import_name_txt);  
  40.             viewHolder.numTextView = (TextView) convertView  
  41.                     .findViewById(R.id.contact_import_num_txt);  
  42.             viewHolder.checkBox = (CheckBox) convertView  
  43.                     .findViewById(R.id.contact_import_checkbox);  
  44.             convertView.setTag(viewHolder);  
  45.   
  46.         } else {  
  47.             viewHolder = (ViewHolder) convertView.getTag();  
  48.         }  
  49.         viewHolder.nameTextView  
  50.                 .setText(dataList.get(position).getContactName());  
  51.         viewHolder.numTextView.setText(dataList.get(position).getContactNum()  
  52.                 .get(0));  
  53.         viewHolder.checkBox.setOnCheckedChangeListener(null);  
  54.         if (dataList.get(position).isCheck()) {  
  55.             viewHolder.checkBox.setChecked(true);  
  56.             viewHolder.checkBox  
  57.                     .setButtonDrawable(R.drawable.xuankuangxuanzhong);  
  58.         } else {  
  59.             viewHolder.checkBox.setChecked(false);  
  60.             viewHolder.checkBox.setButtonDrawable(R.drawable.xuankuangfang);  
  61.         }  
  62.         viewHolder.checkBox  
  63.                 .setOnCheckedChangeListener(new OnCheckedChangeListener() {  
  64.   
  65.                     @Override  
  66.                     public void onCheckedChanged(CompoundButton buttonView,  
  67.                             boolean isChecked) {  
  68.                         if (isChecked) {// 选中  
  69.                             viewHolder.checkBox.setChecked(true);  
  70.                             viewHolder.checkBox  
  71.                                     .setButtonDrawable(R.drawable.xuankuangxuanzhong);  
  72.                             dataList.get(pos).setCheck(true);  
  73.                             int i = getSelectItem().size();  
  74.                             numTextView.setText("已选择"+i+"位联系人");  
  75.                         } else {  
  76.                             viewHolder.checkBox.setChecked(false);  
  77.                             dataList.get(pos).setCheck(false);  
  78.                             viewHolder.checkBox  
  79.                                     .setButtonDrawable(R.drawable.xuankuangfang);  
  80.                             int i = getSelectItem().size();  
  81.                             numTextView.setText("已选择"+i+"位联系人");  
  82.                         }  
  83.   
  84.                     }  
  85.                 });  
  86.         return convertView;  
  87.     }  
  88.       
  89.     public List<ContactBean> getSelectItem(){  
  90.         List<ContactBean> list = new ArrayList<ContactBean>();  
  91.         for (int i = 0; i < dataList.size(); i++) {  
  92.             if(dataList.get(i).isCheck()){  
  93.                 list.add(dataList.get(i));  
  94.             }  
  95.         }  
  96.         return list;  
  97.     }  
  98.       
  99.     @Override  
  100.     public void notifyDataSetChanged() {  
  101.         // TODO Auto-generated method stub  
  102.         super.notifyDataSetChanged();  
  103.         numTextView.setText("已选择"+getSelectItem().size()+"位联系人");  
  104.     }  
  105.       
  106.     public void selectAll(){  
  107.         for (int i = 0; i < dataList.size(); i++) {  
  108.             dataList.get(i).setCheck(true);  
  109.         }  
  110.         notifyDataSetChanged();  
  111.     }  
  112.       
  113.     public void cancelAll(){  
  114.         for (int i = 0; i < dataList.size(); i++) {  
  115.             dataList.get(i).setCheck(false);  
  116.         }  
  117.         notifyDataSetChanged();  
  118.     }  
  119.   
  120.     public static class ViewHolder {  
  121.         private TextView nameTextView;  
  122.         private TextView numTextView;  
  123.         private CheckBox checkBox;  
  124.     }  
  125.   
  126. }  

一对多,多对一的列表适配类ContactSameNameListAdapter

[java] view plain copy
  1. public class ContactSameNameListAdapter extends BaseAdapter {  
  2.   
  3.     private Context mContext;  
  4.     private List<ContactBean> dataList;  
  5.     private TextView numTextView;  
  6.     private int type;//1为name2为phone  
  7.     private List<HashSet<String>> selectSet = new ArrayList<HashSet<String>>();  
  8.     public ContactSameNameListAdapter(Context context, List<ContactBean> list,  
  9.             TextView numTextView,int type) {  
  10.         this.mContext = context;  
  11.         this.dataList = list;  
  12.         this.numTextView = numTextView;  
  13.         this.type = type;  
  14.         for (int i = 0;dataList!=null&&i < dataList.size(); i++) {  
  15.             HashSet<String> set = new HashSet<String>();  
  16.             selectSet.add(set);  
  17.         }  
  18.     }  
  19.   
  20.     @Override  
  21.     public int getCount() {  
  22.         // TODO Auto-generated method stub  
  23.         return dataList != null ? dataList.size() : 0;  
  24.     }  
  25.   
  26.     @Override  
  27.     public Object getItem(int position) {  
  28.         // TODO Auto-generated method stub  
  29.         return position;  
  30.     }  
  31.   
  32.     @Override  
  33.     public long getItemId(int position) {  
  34.         // TODO Auto-generated method stub  
  35.         return position;  
  36.     }  
  37.   
  38.     @Override  
  39.     public View getView(int position, View convertView, ViewGroup parent) {  
  40.         final ViewHolder viewHolder;  
  41.         if (convertView == null) {  
  42.             viewHolder = new ViewHolder();  
  43.             convertView = LayoutInflater.from(mContext).inflate(  
  44.                     R.layout.item_contact_same_name_listview, null);  
  45.             viewHolder.nameTextView = (TextView) convertView  
  46.                     .findViewById(R.id.contact_import_same_txt);  
  47.             viewHolder.listview = (ListView) convertView  
  48.                     .findViewById(R.id.contact_import_same_listview);  
  49.             convertView.setTag(viewHolder);  
  50.   
  51.         } else {  
  52.             viewHolder = (ViewHolder) convertView.getTag();  
  53.         }  
  54.           
  55.         ContactsSameItemListAdapter adapter = new ContactsSameItemListAdapter(  
  56.                 mContext, dataList.get(position),dataList,position,numTextView,selectSet.get(position));  
  57.         viewHolder.listview.setAdapter(adapter);  
  58.         viewHolder.listview.setDividerHeight(0);  
  59.         viewHolder.nameTextView  
  60.                 .setText(dataList.get(position).getContactName());  
  61.         setGridViewHeightBasedOnChildren(viewHolder.listview);  
  62.         return convertView;  
  63.     }  
  64.       
  65.     public List<ContactBean> getSelectItem(){  
  66.         List<ContactBean> alist = new ArrayList<ContactBean>();  
  67.         for (int i = 0; i < dataList.size(); i++) {  
  68.             if(dataList.get(i).getPositon()>=0){  
  69.                 ContactBean contactBean = new ContactBean();  
  70.                 contactBean.setCheck(true);  
  71.                 if(type==1){  
  72.                     contactBean.setContactName(dataList.get(i).getContactName());  
  73.                     List<String> strlist = new ArrayList<String>();  
  74.                     strlist.add(dataList.get(i).getContactNum().get(dataList.get(i).getPositon()));  
  75.                     contactBean.setContactNum(strlist);  
  76.                 }else{  
  77.                     contactBean.setContactName(dataList.get(i).getContactNum().get(dataList.get(i).getPositon()));  
  78.                     List<String> strlist = new ArrayList<String>();  
  79.                     strlist.add(dataList.get(i).getContactName());  
  80.                     contactBean.setContactNum(strlist);  
  81.                 }  
  82.                   
  83.                 alist.add(contactBean);  
  84.                   
  85.             }  
  86.         }  
  87.         return alist;  
  88.     }  
  89.     @Override  
  90.     public void notifyDataSetChanged() {  
  91.         // TODO Auto-generated method stub  
  92.         super.notifyDataSetChanged();  
  93.         numTextView.setText("已选择" + getSelectItem().size() + "位联系人");  
  94.     }  
  95.   
  96.     public void selectAll() {  
  97.         for (int i = 0; i < dataList.size(); i++) {  
  98.             dataList.get(i).setCheck(true);  
  99.         }  
  100.         notifyDataSetChanged();  
  101.     }  
  102.   
  103.     public void cancelAll() {  
  104.         for (int i = 0; i < dataList.size(); i++) {  
  105.             dataList.get(i).setCheck(false);  
  106.         }  
  107.         notifyDataSetChanged();  
  108.     }  
  109.   
  110.     public static class ViewHolder {  
  111.         private TextView nameTextView;  
  112.         private ListView listview;  
  113.     }  
  114.       
  115.     public void setGridViewHeightBasedOnChildren(ListView listView) {  
  116.         // 获取GridView对应的Adapter  
  117.   
  118.         if (listView == null) {  
  119.             return;  
  120.         }  
  121.         ListAdapter listAdapter = listView.getAdapter();  
  122.         if (listAdapter == null) {  
  123.             return;  
  124.         }  
  125.   
  126.         int totalHeight = 0;  
  127.         for (int i = 0; i < listAdapter.getCount(); i++) {  
  128.             View listItem = listAdapter.getView(i, null, listView);  
  129.             listItem.measure(00);  
  130.             totalHeight += listItem.getMeasuredHeight();  
  131.         }  
  132.         ViewGroup.LayoutParams params = listView.getLayoutParams();  
  133.         params.height = totalHeight  
  134.                 + (listView.getDividerHeight() * (listAdapter.getCount() - 1));  
  135.         listView.setLayoutParams(params);  
  136.     }  
  137.   
  138. }  


列表中列表的适配类ContactsSameItemListAdapter

[java] view plain copy
  1. public class ContactsSameItemListAdapter extends BaseAdapter {  
  2.   
  3.     private Context mContext;  
  4.     private ContactBean dataList;  
  5.     private HashSet<String> selectSect;  
  6.     private List<ContactBean> list;  
  7.     private int seposi;  
  8.     private TextView numTextView;  
  9.   
  10.     public ContactsSameItemListAdapter(Context context, ContactBean list,  
  11.             List<ContactBean> mlist, int seposi, TextView textView,  
  12.             HashSet<String> selectSet) {  
  13.         this.mContext = context;  
  14.         this.dataList = list;  
  15.         this.list = mlist;  
  16.         this.seposi = seposi;  
  17.         this.numTextView = textView;  
  18.         this.selectSect = selectSet;  
  19.     }  
  20.   
  21.     @Override  
  22.     public int getCount() {  
  23.         // TODO Auto-generated method stub  
  24.         return dataList != null ? dataList.getContactNum().size() : 0;  
  25.     }  
  26.   
  27.     @Override  
  28.     public Object getItem(int position) {  
  29.         // TODO Auto-generated method stub  
  30.         return position;  
  31.     }  
  32.   
  33.     @Override  
  34.     public long getItemId(int position) {  
  35.         // TODO Auto-generated method stub  
  36.         return position;  
  37.     }  
  38.   
  39.     @Override  
  40.     public View getView(int position, View convertView, ViewGroup parent) {  
  41.         final int pos = position;  
  42.         final ViewHolder viewHolder;  
  43.         if (convertView == null) {  
  44.             viewHolder = new ViewHolder();  
  45.             convertView = LayoutInflater.from(mContext).inflate(  
  46.                     R.layout.item_contact_same_name_import_listview, null);  
  47.             viewHolder.nameTextView = (TextView) convertView  
  48.                     .findViewById(R.id.contact_import_same_name_txt);  
  49.             viewHolder.checkBox = (CheckBox) convertView  
  50.                     .findViewById(R.id.contact_import_same_name_checkbox);  
  51.             viewHolder.lineView = convertView.findViewById(R.id.view_line001);  
  52.             convertView.setTag(viewHolder);  
  53.   
  54.         } else {  
  55.             viewHolder = (ViewHolder) convertView.getTag();  
  56.         }  
  57.   
  58.         if (position == dataList.getContactNum().size() - 1) {  
  59.             viewHolder.lineView.setVisibility(View.GONE);  
  60.         } else {  
  61.             viewHolder.lineView.setVisibility(View.VISIBLE);  
  62.         }  
  63.         viewHolder.nameTextView.setText(dataList.getContactNum().get(position));  
  64.         viewHolder.checkBox.setOnCheckedChangeListener(null);  
  65.         if (selectSect.contains(dataList.getContactNum().get(position))) {  
  66.             viewHolder.checkBox.setChecked(true);  
  67.             viewHolder.checkBox.setButtonDrawable(R.drawable.xuanzhong);  
  68.         } else {  
  69.             viewHolder.checkBox.setChecked(false);  
  70.             viewHolder.checkBox.setButtonDrawable(R.drawable.xuankuang);  
  71.         }  
  72.         viewHolder.checkBox  
  73.                 .setOnCheckedChangeListener(new OnCheckedChangeListener() {  
  74.   
  75.                     @Override  
  76.                     public void onCheckedChanged(CompoundButton buttonView,  
  77.                             boolean isChecked) {  
  78.                         String regEx = "[^0-9]";  
  79.                         Pattern p = Pattern.compile(regEx);  
  80.                         Matcher m = p.matcher(numTextView.getText().toString());  
  81.                         int num = Integer.parseInt(m.replaceAll("").trim());  
  82.                         if (isChecked) {// 选中  
  83.                             viewHolder.checkBox.setChecked(true);  
  84.                             list.get(seposi).setPositon(pos);  
  85.                             if (selectSect.size() == 0) {  
  86.                                 numTextView.setText("已选择" + (num + 1) + "位联系人");  
  87.                             }  
  88.                             selectSect.clear();  
  89.                             selectSect.add(dataList.getContactNum().get(pos));  
  90.                             notifyDataSetChanged();  
  91.                         } else {  
  92.   
  93.                             list.get(seposi).setPositon(-1);  
  94.                             selectSect  
  95.                                     .remove(dataList.getContactNum().get(pos));  
  96.                             viewHolder.checkBox.setChecked(false);  
  97.                             notifyDataSetChanged();  
  98.                             numTextView.setText("已选择" + (num - 1) + "位联系人");  
  99.                         }  
  100.   
  101.                     }  
  102.                 });  
  103.         return convertView;  
  104.     }  
  105.   
  106.     public static class ViewHolder {  
  107.         private TextView nameTextView;  
  108.         private CheckBox checkBox;  
  109.         private View lineView;  
  110.     }  
  111.   
  112. }  


给一个一对多的布局文件

[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:background="@color/bg_gray_login"  
  6.     android:orientation="vertical" >  
  7.     <View   
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="1dp"  
  10.         android:background="#A0A0A0"  
  11.         android:layout_marginTop="5dp"/>  
  12.   
  13.     <LinearLayout  
  14.         android:layout_width="match_parent"  
  15.         android:layout_height="wrap_content"  
  16.         android:background="@color/white"  
  17.         android:orientation="horizontal"  
  18.         android:weightSum="3" >  
  19.   
  20.         <TextView  
  21.             android:id="@+id/contact_import_same_txt"  
  22.             android:layout_width="0dp"  
  23.             android:layout_height="wrap_content"  
  24.             android:layout_gravity="center_vertical"  
  25.             android:layout_marginLeft="15dp"  
  26.             android:layout_marginRight="15dp"  
  27.             android:layout_weight="1"  
  28.             android:gravity="center"  
  29.             android:singleLine="true"  
  30.             android:text="aa"  
  31.             android:textColor="@color/black" />  
  32.   
  33.         <View  
  34.             android:layout_width="1dp"  
  35.             android:layout_height="match_parent"  
  36.             android:layout_marginTop="5dp"  
  37.             android:layout_marginBottom="5dp"  
  38.             android:background="#A0A0A0" />  
  39.   
  40.         <ListView  
  41.             android:id="@+id/contact_import_same_listview"  
  42.             android:layout_width="0dp"  
  43.             android:layout_height="wrap_content"  
  44.             android:layout_weight="2"  
  45.             android:scrollbars="none" >  
  46.         </ListView>  
  47.     </LinearLayout>  
  48.     <View   
  49.         android:layout_width="fill_parent"  
  50.         android:layout_height="1dp"  
  51.         android:background="#A0A0A0"/>  
  52.   
  53. </LinearLayout>  
0 0
原创粉丝点击