skip to Main Content

Android Studio – When the spinner item is selected, I want the button text to be the selected spinner item. or can we just do it in string.xml?

MainActivity.java Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.Door_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); Button button = (Button)findViewById(R.id.Button1); button.setText(spinner.getSelectedItem().toString()); } }

VIEW QUESTION
Back To Top
Search