Apidemos-->Views-Lists-Cursor(people)学习
2020-12-13 04:16
标签:android style http java 使用 strong Views-Lists-Cursor(people)学习,soscw.com" href="http://www.soscw.com/infodetail-253545.html" target="_blank">Apidemos-->Views-Lists-Cursor(people)学习,搜素材,soscw.com Views-Lists-Cursor(people)学习,soscw.com" target="_blank">Apidemos-->Views-Lists-Cursor(people)学习 标签:android style http java 使用 strong 原文地址:http://blog.csdn.net/aikongmeng/article/details/37656781
package com.example.testmyviewslistscursorpeople;
import java.util.ArrayList;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
import android.net.LocalSocketAddress.Namespace;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.text.GetChars;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.example.testmyviewslistsactivateitems.R;
/**
*
* @author Administrator 仿效果slow loading apiDemos -- Views -Lists - Slow Adapter
*/
public class Main extends ListActivity {
private boolean mBusy = false;
public static List
实例源码
protected void getPeople() {
final String[] CONTACT_PROJECTION = new String[] { Contacts._ID,
Contacts.DISPLAY_NAME };
//联系人
Cursor mCursor = getContentResolver().query(Contacts.CONTENT_URI,
CONTACT_PROJECTION, null, null, null);
//联系人电话
Cursor phones = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID, null, null);
while (mCursor.moveToNext()) {
// 获取联系人
String name = mCursor.getString(mCursor
.getColumnIndex(Contacts.DISPLAY_NAME));
mStrings.add(name);
if (phones.moveToNext()) {
//获取电话
String phone = phones.getString(phones
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
mStrings.add(phone);
}
}
//关闭资源
mCursor.close();
phones.close();
}
文章标题:Apidemos-->Views-Lists-Cursor(people)学习
文章链接:http://soscw.com/essay/29271.html