本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Phone.getTypeLabel方法的典型用法代码示例。如果您正苦于以下问题:Java Phone.getTypeLabel方法的具体用法?Java Phone.getTypeLabel怎么用?Java Phone.getTypeLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.provider.ContactsContract.CommonDataKinds.Phone
的用法示例。
在下文中一共展示了Phone.getTypeLabel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemSelected
import android.provider.ContactsContract.CommonDataKinds.Phone; //导入方法依赖的package包/类
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
if (position >= 0) {
//Get current cursor
Cursor c = (Cursor) parent.getItemAtPosition(position);
int type = c.getInt(COLUMN_PHONE_TYPE);
String phone = c.getString(COLUMN_PHONE_NUMBER);
String label = null;
//Custom type? Then get the custom label
if (type == Phone.TYPE_CUSTOM) {
label = c.getString(COLUMN_PHONE_LABEL);
}
//Get the readable string
String numberType = (String) Phone.getTypeLabel(getResources(), type, label);
String text = numberType + ": " + phone;
mPhone.setText(text);
}
}
示例2: phoneTypeToString
import android.provider.ContactsContract.CommonDataKinds.Phone; //导入方法依赖的package包/类
public CharSequence phoneTypeToString(Context mContext, int type, CharSequence label) {
return Phone.getTypeLabel(mContext.getResources(), type, label);
}
示例3: get
import android.provider.ContactsContract.CommonDataKinds.Phone; //导入方法依赖的package包/类
public ArrayList<Contact> get() {
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String[] projection = new String[] {
PhoneLookup._ID,
PhoneLookup.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.TYPE,
ContactsContract.CommonDataKinds.Phone.LABEL,
ContactsContract.CommonDataKinds.Phone.NUMBER
};
String[] simTypesQueryParts = new String[simTypes.length];
Arrays.fill(simTypesQueryParts, ContactsContract.RawContacts.ACCOUNT_TYPE + " <> ?");
String simTypesQuery = TextUtils.join(" AND ", simTypesQueryParts);
String selection = ContactsContract.RawContacts.ACCOUNT_TYPE + " IS NULL OR (" + simTypesQuery + ")";
String[] selectionArgs = simTypes;
Cursor results = resolver.query(
uri,
projection,
selection,
selectionArgs,
null
);
// create array of Phone contacts and fill it
final ArrayList<Contact> phoneContacts = new ArrayList<>();
int indexId = results.getColumnIndex(PhoneLookup._ID);
int indexName = results.getColumnIndex(PhoneLookup.DISPLAY_NAME);
int indexType = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
int indexLabel = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);
int indexNumber = results.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
while (results.moveToNext()) {
int type = results.getInt(indexType);
String custom = results.getString(indexLabel);
final Contact phoneContact = new Contact(
results.getString(indexId),
results.getString(indexName),
results.getString(indexNumber),
(String) Phone.getTypeLabel(this.activity.getResources(), type, custom)
);
phoneContacts.add(phoneContact);
}
results.close();
return phoneContacts;
}
示例4: getTypeLabel
import android.provider.ContactsContract.CommonDataKinds.Phone; //导入方法依赖的package包/类
@Override
public CharSequence getTypeLabel(Resources res, int type, CharSequence label) {
return Phone.getTypeLabel(res, type, label);
}
示例5: phoneTypeToString
import android.provider.ContactsContract.CommonDataKinds.Phone; //导入方法依赖的package包/类
public CharSequence phoneTypeToString(Context mContext, int type, CharSequence label) {
return Phone.getTypeLabel(mContext.getResources(), type, label);
}
示例6: getTypeLabel
import android.provider.ContactsContract.CommonDataKinds.Phone; //导入方法依赖的package包/类
@Override
public CharSequence getTypeLabel(final Resources res,final int type,final CharSequence label)
{
return Phone.getTypeLabel(res,type,label);
}