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