android studio get value of spinner
Spinner mySpinner = (Spinner) findViewById(R.id.your_spinner);
String text = mySpinner.getSelectedItem().toString();
android studio get value of spinner
Spinner mySpinner = (Spinner) findViewById(R.id.your_spinner);
String text = mySpinner.getSelectedItem().toString();
how to set spinner value in android
String compareValue = "some value";
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.select_state, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(adapter);
if (compareValue != null) {
int spinnerPosition = adapter.getPosition(compareValue);
mSpinner.setSelection(spinnerPosition);
}
style for spinner android
<style name="spinner_style">
<item name="android:paddingLeft">0dp</item>
<item name="android:dropDownWidth">533dp</item>
<item name="android:showDividers">none</item>
<item name="android:dividerHeight">0dp</item>
<item name="android:popupBackground">@drawable/new_bg</item>
<item name="android:dropDownHeight">70dp</item>
<item name="android:scrollbarAlwaysDrawVerticalTrack">true</item>
<item name="android:dropDownSelector">@android:color/white</item>
</style>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us