Home Data Changed After set Adapter to Spinner
Reply: 0

Data Changed After set Adapter to Spinner

user1086
1#
user1086 Published in May 27, 2018, 3:34 am

My data always gets size '1' after set to Spinner Adapter. I used SearchableSpinner to show data.

final SearchableSpinner spinnerProvince = selectLocation8v.getSpinnerProvince();

final ArrayList<String> arrayProvince = new ArrayList<>();
final ArrayList<String> arrayKota = new ArrayList<>();
final ArrayList<String> arrayKecamatan = new ArrayList<>();

final ArrayList<State> listProvinsi = lisaDbHelper.getStates();

for (int p = 0; p < listProvinsi.size(); p++) {
    arrayProvince.add(listProvinsi.get(p).getName());
}
ArrayAdapter provinceAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, arrayProvince);
provinceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

spinnerProvince.setAdapter(provinceAdapter);

System.out.println("Data count before set to adapter : " + provinceAdapter.getCount()); // 34

System.out.println("Data count after set to adapter  : " + spinnerProvince.getAdapter().getCount()); // 1
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305678 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO