sunwei07

          Android入門 新手學(xué)習(xí) 開發(fā)

          BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
            4 Posts :: 1 Stories :: 0 Comments :: 0 Trackbacks

          public void onCreate(Bundle savedInstanceState)
           {
            TextView tv = new TextView(this);
            String string = "";  
            super.onCreate(savedInstanceState); 
            //得到ContentResolver對象
                  ContentResolver cr = getContentResolver(); 
                  //取得電話本中開始一項的光標(biāo)
                  Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
                  //向下移動一下光標(biāo)
                  while(cursor.moveToNext())
                  {
                   //取得聯(lián)系人名字
                   int nameFieldColumnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);    
                   String contact = cursor.getString(nameFieldColumnIndex);
                   //取得電話號碼
                   int numberFieldColumnIndex = cursor.getColumnIndex(PhoneLookup.NUMBER);   
                   String number = cursor.getString(numberFieldColumnIndex);
                   
                   string += (contact+":"+number+"\n");
                  }
                  cursor.close();
            //設(shè)置TextView顯示的內(nèi)容
            tv.setText(string);
            //顯示到屏幕
            setContentView(tv);
           }

          posted on 2011-02-15 11:26 sunwei_07 閱讀(358) 評論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 扬中市| 布尔津县| 布拖县| 鄂托克前旗| 江津市| 黄龙县| 武平县| 霍州市| 灵宝市| 北宁市| 东城区| 嘉定区| 墨竹工卡县| 布拖县| 平安县| 年辖:市辖区| 通许县| 梁河县| 乃东县| 吉首市| 高安市| 衢州市| 襄垣县| 武胜县| 桂阳县| 河间市| 错那县| 射阳县| 大洼县| 溆浦县| 石家庄市| 古丈县| 吉木萨尔县| 屯门区| 宜城市| 贡嘎县| 渭源县| 阜康市| 手机| 睢宁县| 图们市|