`

高仿android通讯录

阅读更多
最近都没有时间来更新我的博客,主要是在项目中遇到一些比较棘手的问题需要解决,今天我就把我解决的难题写了个Demo出来与大家一起分享,最终达到火种通讯录联系人界面的效果。
       在这次代码编写当中,我主要用到了WindowManager来显示友好提示

       在对数组进行排序的时候,我们可以用 Arrays.sort()方法轻松实现按字母顺序排序。

       另外在实现点击字母后让ListView滚动到以该字母开头的相应位置效果时,我们要用到如下方法:

       一个是通过public static int binarySearch(Object[] a,Object key) 方法来获得该字母出现的Item在ListView中的位置position,

       另一个就是 list.setSelection(localPosition); 来让List指向对应位置的Item。

       当你对这些方法都有所了解了以后,下面我们开始设计我们的Demo。

        我们先建立一个名为ContactsDemo的工程,然后就是代码部分了:

第一步,在res/layout的main.xml中我们来设置Activity中显示ListView上下层显示的效果,其实就是一个相对布局。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<ListView  
 android:id="@+id/list"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    />
<ListView
 android:id="@+id/listview" 
 android:layout_width="30dip"
 android:layout_height="wrap_content"
 android:layout_centerInParent="true"
 android:layout_alignParentTop="true"
 android:layout_alignParentRight="true"
 android:background="@null"
 />    
</RelativeLayout>

第二步,我们在layout中建一个list_popup_char_hint.xml,这是用来通过WindowManager显示友好提示的。

<?xml version="1.0" encoding="utf-8"?>  
<TextView xmlns:android="http://schemas.android.com/apk/res/android"  
    android:textSize="70sp"  
    android:textColor="#ffffffff"  
    android:minWidth="70dip"  
    android:maxWidth="70dip"  
    android:padding="10dip"  
    android:gravity="center"  
/>  

第三步,是list_item.xml用来设置ListView中Items的布局。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
      <TextView android:id="@+id/text_first_char_hint"  
        android:layout_width="fill_parent"  
        android:layout_height="wrap_content"  
        android:textSize="20dip"  
        android:paddingLeft="10dip"  
        android:background="@drawable/background"
        android:visibility="gone">  
    </TextView>  
    <LinearLayout 
  android:orientation="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <TextView
   android:id="@+id/order"
   android:layout_width="wrap_content"
   android:layout_height="60dip"
   android:textSize="15dip"
   android:layout_gravity="left"
   android:layout_weight="2"/>
  <TextView
   android:id="@+id/content"
   android:gravity="center"
   android:layout_width="wrap_content"
   android:layout_height="60dip"
   android:textSize="15dip"
   android:layout_weight="2"/>
    </LinearLayout >
</LinearLayout >

第四步,是一个textview.xml用来显示右边覆盖在ListView上的ListView的Items

<?xml version="1.0" encoding="utf-8"?>
<TextView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:textSize="20dip">
</TextView>

第五步,我们建一个名为ContactsDemo的类,然后就是实现功能的代码了,里面有非常详尽的注释,大家慢慢看吧。

package com.ContactsDemo;

import java.util.ArrayList;
import java.util.Arrays;

import android.app.Activity;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView.OnItemClickListener;

/**
 * @author Mr.罗
 *
 */
public class ContactsDemo extends Activity implements OnItemClickListener,OnScrollListener{
    /** Called when the activity is first created. */
 private MyListAdapter  adapter;
 private ArrayList<String> webNameArr;   
    private WindowManager windowManager; 
    private TextView txtOverlay;   //用来放在WindowManager中显示提示字符
    private Handler handler;   
    private DisapearThread disapearThread;   
    private int scrollState;  //滚动的状态
    private ListView list,listview;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        txtOverlay = (TextView) LayoutInflater.from(this).inflate(R.layout.list_popup_char_hint, null);   
        // 默认设置为不可见。   
        txtOverlay.setVisibility(View.INVISIBLE);  
        //设置WindowManager
        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(LayoutParams.WRAP_CONTENT,   
                LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION,   
                //设置为无焦点状态
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, 
                //半透明效果
                PixelFormat.TRANSLUCENT);   
        windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);   
        windowManager.addView(txtOverlay, lp); 
        
        handler = new Handler();   
        disapearThread = new DisapearThread();  

        Arrays.sort(stringArr,String.CASE_INSENSITIVE_ORDER); //大小写不敏感
        webNameArr = new ArrayList<String>();     
        for (int i = 0; i < stringArr.length; i++) {   
            webNameArr.add(stringArr[i]);      
        }   
       
        
        list = (ListView)this.findViewById(R.id.list); //联系人ListView
        listview = (ListView)this.findViewById(R.id.listview); //拼音查询ListView
        
        adapter = new MyListAdapter(this); 
        list.setAdapter(adapter);//将数据适配器与Activity进行绑定
        list.setOnScrollListener(this); 
        
        ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this,R.layout.textview,py);
        listview.setAdapter(adapter1);
        
        listview.setDivider(null);
        listview.setOnItemClickListener(this);
    }
    
    
    private class DisapearThread implements Runnable {   
        public void run() {   
            // 避免在1.5s内,用户再次拖动时提示框又执行隐藏命令。   
            if (scrollState == ListView.OnScrollListener.SCROLL_STATE_IDLE) {   
                txtOverlay.setVisibility(View.INVISIBLE);   
            }   
        }   
    }  
    
    //继承BaseAdapter来设置ListView每行的内容
    public final  class ViewHolder {   
        public TextView firstCharHintTextView;   
        public TextView orderTextView;   
        public TextView nameTextView;   
        public TextView urlTextView;   
        public ImageView imgView;   
    }   
    private class MyListAdapter extends BaseAdapter {   
        private LayoutInflater inflater;   
        public MyListAdapter(Context context) {   
            this.inflater = LayoutInflater.from(context);   
        }   
        public int getCount() {   
            return  webNameArr.size();   
        }   
        public Object getItem(int position) {   
            return webNameArr.get(position);   
        }   
        public long getItemId(int position) {   
            return position;   
        }   
        public View getView(final int position, View convertView, ViewGroup parent) {   
            ViewHolder holder = null;   
            if (convertView == null) {   
                convertView = inflater.inflate(R.layout.list_item, null);   
                holder = new ViewHolder();   
                holder.firstCharHintTextView = (TextView) convertView.findViewById(R.id.text_first_char_hint);   
                holder.orderTextView = (TextView) convertView.findViewById(R.id.order);          
                holder.nameTextView = (TextView) convertView.findViewById(R.id.content);     
                convertView.setTag(holder);   
            } else {   
                holder = (ViewHolder) convertView.getTag();   
            }   
            holder.orderTextView.setText(String.valueOf(position + 1) + ".");   
            holder.nameTextView.setText(webNameArr.get(position));      
            int idx = position - 1;   
            //判断前后Item是否匹配,如果不匹配则设置并显示,匹配则取消
            char previewChar = idx >= 0 ? stringArr[idx].charAt(0) : ' ';   
            char currentChar = stringArr[position].charAt(0); 
            //将小写字符转换为大写字符
            char newPreviewChar = Character.toUpperCase(previewChar);  
            char newCurrentChar = Character.toUpperCase(currentChar);  
            if (newCurrentChar != newPreviewChar) {   
                holder.firstCharHintTextView.setVisibility(View.VISIBLE);   
                holder.firstCharHintTextView.setText(String.valueOf(newCurrentChar));   
            } else {   
                // 此段代码不可缺:实例化一个CurrentView后,会被多次赋值并且只有最后一次赋值的position是正确   
                holder.firstCharHintTextView.setVisibility(View.GONE);   
            }   
            return convertView;   
        }   
    }   
    
 public void onScroll(AbsListView view, int firstVisibleItem,
   int visibleItemCount, int totalItemCount) { 
   // 以中间的ListItem为标准项来显示。   
        txtOverlay.setText(String.valueOf(stringArr[firstVisibleItem + (visibleItemCount >> 1)].charAt(0)).toUpperCase());   
 }
 public void onScrollStateChanged(AbsListView view, int scrollState) { 
  this.scrollState = scrollState;   
        if (scrollState == ListView.OnScrollListener.SCROLL_STATE_IDLE) {   
            handler.removeCallbacks(disapearThread);   
            // 提示延迟1.5s再消失   
            handler.postDelayed(disapearThread, 1500);    
        } else {   
            txtOverlay.setVisibility(View.VISIBLE);   
        } 
 }
 public void onItemClick(AdapterView<?> parent, View view, int position,
   long id) {
    
  String s = ((TextView)view).getText().toString();
   txtOverlay.setText(s);
   txtOverlay.setVisibility(View.VISIBLE);
   handler.removeCallbacks(disapearThread);  
   // 提示延迟1.5s再消失   
         handler.postDelayed(disapearThread, 1500); 
          
       int localPosition = binSearch(stringArr,s); //接收返回值

       if(localPosition!=-1){
     txtOverlay.setVisibility(View.INVISIBLE); //防止点击出现的txtOverlay与滚动出现的txtOverlay冲突
        list.setSelection(localPosition); //让List指向对应位置的Item
       }
 }
 //将选中的py与stringArr的首字符进行匹配并返回对应字符串在数组中的位置
 public static int binSearch(String[] string , String s ){
  for(int i=0;i<string.length;i++){
   if(s.equalsIgnoreCase(""+string[i].charAt(0))){ //不区分大小写
    return i;
   }
  }
  return -1;
  
 }
 
  public void onDestroy() {   
         super.onDestroy();   
         // 将txtOverlay删除。   
         txtOverlay.setVisibility(View.INVISIBLE);   
         windowManager.removeView(txtOverlay);   
     }   
      
 /**在这里我们将字符串打乱,且含有大小写开头不等*/
  private String[] stringArr = { "abbaye de Belloc", "abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi",   
             "Acorn", "Adelost", "Affidelice au Chablis", "afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre",   
             "Allgauer Emmentaler", "Alverca", "ambert", "american Cheese", "Ami du Chambertin", "Anejo Enchilado",   
             "brebis du Lochois", "brebis du Puyfaucon", "aresse Bleu", "Ardi Gasna", "Ardrahan", "Armenian String",   
             "Aromes au Gene de Marc", "asadero", "asiago", "Aubisque Pyrenees", "Autun", "Avaxtskyr", "Baby Swiss",   
             "Babybel", "Baguette Laonnaise", "Bakers", "Baladi", "Balaton", "bandal", "Banon", "Barry's Bay Cheddar",   
             "Basing", "Basket Cheese", "Bath Cheese", "Bavarian Bergkase", "Baylough", "Beaufort", "Beauvoorde",   
             "Beenleigh Blue", "Beer Cheese", "Bel Paese", "Bergader", "Bergere Bleue", "Berkswell", "Beyaz Peynir",   
             "Bierkase", "Bishop Kennedy", "Blarney", "Bleu d'Auvergne", "Bleu de Gex", "Bleu de Laqueuille",   
             "Bleu de Septmoncel", "Bleu Des Causses", "Blue", "Blue Castello", "Blue Rathgore",   
             "Blue Vein (Australian)", "Blue Vein Cheeses", "Bocconcini", "Bocconcini (Australian)",   
             "Boeren Leidenkaas", "Bonchester", "Bosworth", "Bougon", "Boule Du Roves", "Boulette d'Avesnes",   
             "Boursault", "Boursin", "eouyssou", "Bra", "Braudostur", "Breakfast Cheese", "Brebis du Lavort",   
             "Allgauer Emmentaler", "Alverca", "Ambert",  "Brick", "Brie", "Brie de Meaux",   
             "Brie de Melun", "Brillat-Savarin", "Brin", "Brin d' Amour", "Brin d'Amour", "Brinza (Burduf Brinza)",   
             "Briquette de Brebis", "driquette du Forez", "Broccio", "Broccio Demi-Affine", "Brousse du Rove",   
             "Bruder Basil", "Brusselae Kaas (Fromage de Bruxelles)", "Bryndza", "Buchette d'Anjou", "Buffalo",   
             "Burgos", "Butte", "Butterkase", "Button (Innes)", "Buxton Blue", "Cabecou", "Caboc", "Cabrales",   
             "Cachaille", "Caciocavallo", "Caciotta", "Caerphilly", "Cairnsmore", "Calenzana", "Cambazola",   
             "Camembert de Normandie", "Canadian Cheddar", "Canestrato", "Cantal", "Caprice des Dieux",   
             "Capricorn Goat", "Capriole Banon", "Carre de l'Est", "Casciotta di Urbino", "Cashel Blue", "Castellano",   
             "Castelleno", "Castelmagno", "Castelo Branco", "Castigliano", "Cathelain", "Celtic Promise",   
             "Cendre d'Olivet", "Cerney", "Chabichou", "Chabichou du Poitou", "Chabis de Gatine", "Chaource",   
             "Charolais", "Chaumes", "Cheddar", "Cheddar Clothbound", "Cheshire", "Chevres", "Chevrotin des Aravis",   
             "Derby", "Dessertnyj Belyj", "Devon Blue", "Devon Garland", "Coeur de Chevre", "Colby", "Cold Pack", "Comte",   
             "Coolea", "Cooleney", "Coquetdale", "Corleggy", "Cornish Pepper", "Cotherstone", "Cotija",   
             "Cottage Cheese", "Cottage Cheese (Australian)", "Cougar Gold", "Coulommiers", "Coverdale",   
             "Crayeux de Roncq", "Cream Cheese", "Cream Havarti", "Crema Agria", "Crema Mexicana", "Creme Fraiche",   
             "Crescenza", "Croghan", "Crottin de Chavignol", "frottin du Chavignol", "Crowdie", "Crowley", "Cuajada",   
             "Curd", "Cure Nantais", "Curworthy", "Cwmtawe Pecorino", "Cypress Grove Chevre", "Danablu (Danish Blue)",   
             "Danbo", "Danish Fontina", "Daralagjazsky", "Dauphin", "Delice des Fiouves", "Denhany Dorset Drum",   
             "Derby", "Dessertnyj Belyj", "Devon Blue", "Devon Garland", "Dolcelatte", "Doolin", "Doppelrhamstufel",   
             "Dorset Blue Vinney", "Double Gloucester", "Double Worcester", "Dreux a la Feuille", "Dry Jack",   
             "Duddleswell", "Dunbarra", "Dunlop", "Dunsyre Blue", "Duroblando", "Durrus",   
             "Dutch Mimolette (Commissiekaas)", "Edam", "Edelpilz", "Emental Grand Cru", "Emlett", "Emmental",   
             "Epoisses de Bourgogne", "Esbareich", "Esrom", "Etorki", "Evansdale Farmhouse Brie", "Evora De L'Alentejo",   
             "Exmoor Blue", "Explorateur", "Feta", "Feta (Australian)", "Figue", "Filetta", "Fin-de-Siecle",   
             "Finlandia Swiss", "Finn", "Fiore Sardo", "Fleur du Maquis", "Flor de Guia", "Flower Marie", "Folded",   
             "Folded cheese with mint", "Fondant de Brebis", "Fontainebleau", "Fontal", "Fontina Val d'Aosta",   
             "Formaggio di capra", "Fougerus", "Four Herb Gouda", "Fourme d' Ambert", "Fourme de Haute Loire",   
             "Fourme de Montbrison", "Fresh Jack", "Fresh Mozzarella", "Fresh Ricotta", "Fresh Truffles",   
             "Fribourgeois", "Friesekaas", "Friesian", "Friesla", "Frinault", "Fromage a Raclette", "Fromage Corse",   
             "Fromage de Montagne de Savoie", "Fromage Frais", "Fruit Cream Cheese", "Frying Cheese", "Fynbo",   
             "Gabriel", "Galette du Paludier", "kalette Lyonnaise", "Galloway Goat's Milk Gems", "Gammelost",   
             "Gaperon a l'Ail", "Garrotxa", "Gastanberra", "Geitost", "Gippsland Blue", "Gjetost", "Gloucester",   
             "Golden Cross", "Gorgonzola", "Gornyaltajski", "Gospel Green", "Gouda", "Goutu", "Gowrie", "Grabetto",   
             "Graddost", "Grafton Village Cheddar", "Grana", "Grana Padano", "Grand Vatel", "Grataron d' Areches",   
             "Gratte-Paille", "Graviera", "Greuilh", "Greve", "Gris de Lille", "Gruyere", "Gubbeen", "Guerbigny",   
             "Halloumi", "Halloumy (Australian)", "Haloumi-Style Cheese", "Harbourne Blue", "Havarti", "Heidi Gruyere",   
             "Hereford Hop", "Herrgardsost", "Herriot Farmhouse", "Herve", "Hipi Iti", "Hubbardston Blue Cow",   
             "Hushallsost", "Iberico", "Idaho Goatster", "Idiazabal", "Il Boschetto al Tartufo", "Ile d'Yeu",   
             "Isle of Mull", "Jarlsberg", "Jermi Tortes", "Jibneh Arabieh", "Jindi Brie", "Jubilee Blue", "Juustoleipa",   
             "Kadchgall", "Kaseri", "Kashta", "Kefalotyri", "Kenafa", "Kernhem", "Kervella Affine", "Kikorangi",   
             "King Island Cape Wickham Brie", "King River Gold", "Klosterkaese", "Knockalara", "Kugelkase",   
             "L'Aveyronnais", "L'Ecir de l'Aubrac", "La Taupiniere", "La Vache Qui Rit", "Laguiole", "Lairobell",   
             "Lajta", "Lanark Blue", "Lancashire", "Langres", "Lappi", "Laruns", "Lavistown", "Le Brin", "Le Fium Orbo",   
             "Le Lacandou", "Le Roule", "Leafield", "Lebbene", "Leerdammer", "Leicester", "Leyden", "Limburger",   
             "Lincolnshire Poacher", "Lingot Saint Bousquet d'Orb", "Liptauer", "Little Rydings", "Livarot",   
             "Llanboidy", "Llanglofan marmhouse", "Loch Arthur Farmhouse", "Loddiswell Avondale", "Longhorn",   
             "Lou Palou", "Lou Pevre", "Lyonnais", "Maasdam", "Macconais", "Mahoe Aged Gouda", "Mahon", "Malvern",   
             "Mamirolle", "Manchego", "Manouri", "Manur", "Marble Cheddar", "Marbled Cheeses", "Maredsous", "Margotin",   
             "Maribo", "Maroilles", "Mascares", "Mascarpone", "Mascarpone (Australian)", "Mascarpone Torta", "Matocq",   
             "Maytag Blue", "Meira", "Menallack Farmhouse", "Menonita", "Meredith Blue", "Mesost",   
             "Metton (Cancoillotte)", "Meyer Vintage Gouda", "Mihalic Peynir", "Milleens", "Mimolette", "Mine-Gabhar",   
             "Mini Baby Bells", "Mixte", "Molbo", "Monastery Cheeses", "Mondseer", "Mont D'or Lyonnais", "Montasio",   
             "Monterey Jack", "Monterey Jack Dry", "Morbier", "Morbier Cru de Montagne", "Mothais a la Feuille",   
             "Mozzarella", "Mozzarella (Australian)", "Mozzarella di Bufala", "Mozzarella Fresh, in water",   
             "Mozzarella Rolls", "Munster", "Murol", "Mycella", "Myzithra", "Naboulsi", "Nantais", "Neufchatel",   
             "Neufchatel (Australian)", "Niolo", "Nokkelost", "Northumberland", "Oaxaca", "Olde York", "Olivet au Foin",   
             "Olivet Bleu", "Olivet Cendre", "Orkney Extra Mature Cheddar", "Orla", "Oschtjepka", "Ossau Fermier",   
             "Ossau-Iraty", "Oszczypek", "Oxford Blue", "P'tit Berrichon", "Palet de Babligny", "Paneer", "Panela",   
             "Pannerone", "Pant ys Gawn", "Parmesan (Parmigiano)", "Parmigiano Reggiano", "Pas de l'Escalette",   
             "Passendale", "Pasteurized Processed", "Pate de Fromage", "Patefine Fort", "Pave d'Affinois",   
             "Pave d'Auge", "Pave de Chirac", "Pave du Berry", "Pecorino", "Pecorino in Walnut Leaves",   
             "Pecorino Romano", "Peekskill Pyramid", "Pelardon des Cevennes", "Pelardon des Corbieres", "Penamellera",   
             "Hereford Hop", "Herrgardsost", "Herriot Farmhouse", "Petit Pardou", "Petit-Suisse",   
             "Picodon de Chevre", "Picos de Europa", "Piora", "Pithtviers au Foin", "Plateau de Herve",   
             "Plymouth Cheese", "Podhalanski", "Poivre d'Ane", "Polkolbin", "Pont l'Eveque", "Port Nicholson",   
             "Port-Salut", "Postel", "Pouligny-Saint-Pierre", "Pourly", "Prastost", "Pressato", "Prince-Jean",   
             "Processed Cheddar", "Provolone", "Provolone (Australian)", "Pyengana Cheddar", "Pyramide", "Quark",   
             "Quark (Australian)", "Quartirolo Lombardo", "Quatre-Vents", "Quercy Petit", "Queso Blanco",   
             "Queso Blanco con Frutas --Pina y Mango", "Queso de Murcia", "Queso del Montsec", "Queso del Tietar",   
             "Queso Fresco", "Queso Fresco (Adobera)", "Queso Iberico", "Queso Jalapeno", "Queso Majorero",   
             "Queso Media Luna", "Queso Para Frier", "Queso Quesadilla", "Rabacal", "Raclette", "Ragusano", "Raschera",   
             "Reblochon", "Red Leicester", "Regal de la Dombes", "Reggianito", "Remedou", "Requeson", "Richelieu",   
             "Ricotta", "Ricotta (Australian)", "Ricotta Salata", "Ridder", "Rigotte", "Rocamadour", "Rollot", "Romano",   
             "Romans Part Dieu", "Roncal", "Roquefort", "Roule", "Rouleau De Beaulieu", "Royalp Tilsit", "Rubens",   
             "Rustinu", "Saaland Pfarr", "Saanenkaese", "Saga", "Sage Derby", "Sainte Maure", "Saint-Marcellin",   
             "Saint-Nectaire", "Saint-Paulin", "Salers", "Samso", "San Simon", "Sancerre", "Sap Sago", "Sardo",   
             "Sardo Egyptian", "Sbrinz", "Scamorza", "Schabzieger", "Schloss", "Selles sur Cher", "Selva", "Serat",   
             "Seriously Strong Cheddar", "Serra da Estrela", "Sharpam", "Shelburne Cheddar", "Shropshire Blue", "Siraz",   
             "Sirene", "Smoked Gouda", "Somerset Brie", "Sonoma Jack", "Sottocenare al Tartufo", "Soumaintrain",   
             "Sourire Lozerien", "Spenwood", "Sraffordshire Organic", "St. Agur Blue Cheese", "Stilton",   
             "Stinking Bishop", "String", "Sussex Slipcote", "Sveciaost", "Swaledale", "Sweet Style Swiss", "Swiss"
               };
  private String py[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R"
    ,"S","T","U","V","W","X","Y","Z"};
}
分享到:
评论
4 楼 蓝月儿 2012-08-09  
有图片吗,有图片会更好些
3 楼 yzx503319102 2011-11-25  
楼主最好加上效果图 这样会比较好
2 楼 aichixihongshi 2011-09-28  
中文转成字母不就ok了吗,网上有例子。过段时间 我再把中文的贴上
1 楼 阿顺顺 2011-09-28  
LZ 的排序全部都是英文,可是中文的,就无法排序了!!最近要做用户列表的排序,类似Android联系人,有字母的快速索引以定位,不知LZ有没有好的办法??我Q:914575565

相关推荐

    高仿微信通讯录

    【高仿微信通讯录】是针对移动应用开发者的一项技术挑战,旨在实现与微信类似的通讯录功能,提供用户友好的界面和流畅的操作体验。这个项目通常包括数据管理、UI设计、搜索功能、联系人分组等多个方面的开发工作。...

    高仿微信通讯录列表

    首先,"高仿微信通讯录列表"指的是创建一个与微信应用中通讯录界面相似的用户界面。这个界面通常包括一个可滚动的联系人列表,每个联系人的名字按照拼音或笔画排序,并且在列表的侧边有一条滑动字母导航栏。当用户...

    reactnative触摸事件机制详解及高仿微信通讯录功能

    4. **高仿微信通讯录功能**:实现类似微信通讯录的功能,需要创建一个可滚动的列表,每个联系人项都是一个可触摸的元素。可以使用`FlatList`组件来实现长列表的高效渲染。每个列表项包含姓名、头像等信息,并绑定`...

    高仿手机通讯录app

    在Android开发领域,创建一个高仿手机通讯录的App是一项常见的任务,这涉及到对系统核心组件的理解和使用,特别是“内容提供者”(Content Provider)这一关键组件。本项目主要涵盖了如何利用内容提供器实现数据的...

    Android高仿QQ通讯录最终版

    由于之前上传的资源不能删除 这版本相对2013.12.3号的版本做了不少改动 将界面进行了更新 解决不少自测出现的问题 增加一些新的功能等 详细信息参考 http://blog.csdn.net/huahuadashen/article/details/15506151

    android高仿苹果的通讯录,4.3以上及以下版本通用

    【Android 高仿苹果通讯录实现详解】 在Android平台上,开发者常常希望为用户提供与iOS类似的操作体验,特别是在设计用户界面时。本项目“android高仿苹果的通讯录”旨在实现一个兼容Android 4.3及以上及以下版本的...

    高仿qq通讯录

    【标题】"高仿qq通讯录"所涉及的IT知识点主要集中在移动应用开发领域,特别是Android平台上的应用设计和编程。QQ通讯录是一款广受欢迎的手机应用,它提供了联系人管理、聊天、通话等多种功能。高仿qq通讯录意味着...

    高仿通讯录字母选择

    在Android开发中,"高仿通讯录字母选择"是一个常见的功能,它允许用户通过点击字母导航栏快速定位到联系人的姓名。这个功能在许多应用程序,尤其是通讯类应用中被广泛使用,因为它提供了高效的查找体验。在给定的...

    仿钉钉组织架构通讯录功能

    在IT行业中,构建高效的企业级应用是至关重要的,而“仿钉钉组织架构通讯录功能”就是一个典型的需求,尤其在企业协作和管理软件中。钉钉作为一款知名的办公软件,其组织架构通讯录功能深受用户喜爱,因为它能够清晰...

    基于Android Studio开发的安卓的高仿微信

    在本文中,我们将深入探讨如何基于Android Studio开发一个高仿微信的应用程序。Android Studio是Google提供的官方集成开发环境(IDE),特别适用于Android应用的开发。它提供了丰富的工具集,包括代码编辑器、调试器...

    CalendarExaple-master仿钉钉、小米日历

    【标题】"CalendarExample-master仿钉钉、小米日历"是一个Android开发项目,旨在实现类似钉钉和小米手机日历的应用界面和功能。这个项目主要关注日历视图的展示和交互,包括日历的收缩与展开、日期的选择以及通过...

    Android应用源码仿QQ列表通讯录项目.zip

    【Android应用源码仿QQ列表通讯录项目】是一个学习和参考的资源,它提供了一个实现类似QQ通讯录功能的Android应用程序的源代码。这个项目旨在帮助开发者理解和掌握Android平台上开发通讯录应用的关键技术和实践。 ...

    Android 完美高仿的微信源码

    【Android 完美高仿的微信源码】是一款基于Android平台开发的,旨在模拟微信功能的应用程序源代码。这个项目通常由资深的Android开发者创建,用于教学、学习或研究目的,帮助开发者理解如何构建类似微信这样的复杂...

    Android-app.rar

    Android软件源码短信通讯录毕设项目带需求报告 Android软件源码类似时间轴记录的记账记事本 Android项目源码 studio和eclipse双版本仿bilibili客户端 Android项目源码GPS实时定位位置共享 Android项目源码QQ登录语音...

    android 高仿微信6.0版本

    在Android开发中,高仿微信6.0版本的实现涉及到了多个关键技术和组件,下面将对这些技术进行详细的解析。 首先,"ViewPager"是Android中用于实现页面滑动切换的重要组件,它允许用户通过左右滑动来浏览多个相互关联...

    android 项目源码下载:12套聊天通讯类项目

    │ Android 公司通讯录(含来电号码姓名查询和搜索功能).rar │ Android 完美高仿的微信源码.rar │ Android 驴友社交系统源码.rar │ Android简单通讯源码:手机控制PC的关机、重启、.rar │ android蓝牙聊天的应用...

    30款APP源码打包.zip

    Android仿赶集生活客户端APP源码,Android仿高德地图APP源码,Android仿开心网APP源码,Android仿美团界面APP源码,Android高仿陌陌APP源码,Android高仿奇艺APP源码,Android腾讯通讯录管理源码....共30款APP源码

    Android仿微信通讯录列表侧边栏效果

    在Android开发中,实现“仿微信通讯录列表侧边栏效果”是一种常见需求,它可以提供用户友好的体验,便于快速定位联系人。该效果的主要特点是根据联系人的首字符拼音进行排序,并通过侧边栏的字母索引来定位。下面将...

Global site tag (gtag.js) - Google Analytics