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

How to add data into Spinner in android – CPanel

In my application I want show some data from server into Spinner. For Spinner I use this library : https://github.com/ganfra/MaterialSpinner My Json : "stars": [ { "id": 105076, "name": "Eleanor Tomlinson", "character": null, "imageUrl": "http://example.com/cpanel/uploads/Celebrities/105076/thumb2-SK4MPEGW09.jpg", "userReview": "" }, { "id":…

VIEW QUESTION
Back To Top
Search