1 2 3 4 5 6 7 8 9 10 11 | // you need to have a list of data that you want the spinner to display List<String> spinnerArray = new ArrayList<String>(); spinnerArray.add("item1"); spinnerArray.add("item2"); ArrayAdapter<String> adapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_item, spinnerArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner sItems = (Spinner) findViewById(R.id.spinner1); sItems.setAdapter(adapter); | cs |
https://stackoverflow.com/questions/11920754/android-fill-spinner-from-java-code-programmatically
https://stackoverflow.com/questions/11920754/android-fill-spinner-from-java-code-programmatically
https://stackoverflow.com/questions/11920754/android-fill-spinner-from-java-code-programmatically
'android' 카테고리의 다른 글
[Android] Android Resource 이름으로 id 찾기 (0) | 2019.02.22 |
---|---|
[Android] setUserVisibleHint가 onCreateView보다 먼저 호출될 때 (0) | 2019.02.07 |
[Android] DialogFragment에 기본 padding값 제거하는 방법 (0) | 2019.01.29 |
[Android] Type parameter T Has Incompatible upper bounds ViewDataBinding 대처 (0) | 2019.01.29 |
[Android] 테두리 양쪽 좌우만 설정하기 (1) | 2019.01.25 |