我想让某个国家/地区代码成为默认值,但现在它按升序排列。
我怎样才能做到这一点?
以下是示例代码:
private void initViews() {
registrationBean = new RegistrationBean();
viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper_registration);
viewFlipper.setDisplayedChild(0);
llVerification = (LinearLayout) findViewById(R.id.ll_registration_mobile_otp);
txtVerificationLabel = (TextView) findViewById(R.id.txt_registration_mobile_otp_label);
spinnerCountryCodes = (Spinner) findViewById(R.id.spinner_registration_mobile_country_code);
countryListBean = AppConstants.getCountryBean();
Collections.sort(countryListBean.getCountries());
List<String> countryDialCodes = new ArrayList<>();
for (CountryBean bean : countryListBean.getCountries()) {
countryDialCodes.add(bean.getDialCode());
}
答案 0 :(得分:0)
在for循环之后的第0个索引的列表中添加默认国家/地区代码,如:
for (CountryBean bean : countryListBean.getCountries()) {
countryDialCodes.add(bean.getDialCode());
}
countryDialCodes.add(0, yourDefaultCountryCode);