本文整理匯總了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);
}