本文整理匯總了Java中android.widget.ArrayAdapter.insert方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayAdapter.insert方法的具體用法?Java ArrayAdapter.insert怎麽用?Java ArrayAdapter.insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ArrayAdapter
的用法示例。
在下文中一共展示了ArrayAdapter.insert方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addCardDataToEditFields
import android.widget.ArrayAdapter; //導入方法依賴的package包/類
private void addCardDataToEditFields() {
if (mCard == null) {
mNameLabel.requestFocus();
return;
}
if (!TextUtils.isEmpty(mCard.getName())) {
mNameLabel.getEditText().setText(mCard.getName());
}
if (!TextUtils.isEmpty(mCard.getNumber())) {
mNumberLabel.getEditText().setText(mCard.getNumber());
}
// Make the name label focusable in touch mode so that mNameText doesn't get focused.
mNameLabel.setFocusableInTouchMode(true);
int monthAsInt = 1;
if (!mCard.getMonth().isEmpty()) {
monthAsInt = Integer.parseInt(mCard.getMonth());
}
mInitialExpirationMonthPos = monthAsInt - 1;
mExpirationMonth.setSelection(mInitialExpirationMonthPos);
mInitialExpirationYearPos = 0;
boolean foundYear = false;
for (int i = 0; i < mExpirationYear.getAdapter().getCount(); i++) {
if (mCard.getYear().equals(mExpirationYear.getAdapter().getItem(i))) {
mInitialExpirationYearPos = i;
foundYear = true;
break;
}
}
// Maybe your card expired years ago? Add the card's year
// to the spinner adapter if not found.
if (!foundYear && !mCard.getYear().isEmpty()) {
@SuppressWarnings("unchecked")
ArrayAdapter<CharSequence> adapter =
(ArrayAdapter<CharSequence>) mExpirationYear.getAdapter();
adapter.insert(mCard.getYear(), 0);
mInitialExpirationYearPos = 0;
}
mExpirationYear.setSelection(mInitialExpirationYearPos);
}