Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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);
}
Comment

how to set current item for spinner android

val b: List<Int> = a.mapIndexed { i, b -> if (b) i else null }.filterNotNull().toList()

spinnerObject.setSelection(b.get(0))
Comment

PREVIOUS NEXT
Code Example
Java :: {} when initialising arraylist java 
Java :: what is the use of println 
Java :: java 2d array for each 
Java :: create new java swing button 
Java :: update query jpa 
Java :: java negative infinity 
Java :: Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema 
Java :: how to remove spaces from an array in java 
Java :: Java debug log 
Java :: how to write a json file using java 
Java :: data java 
Java :: java join list as string 
Java :: How to perform a breadth first search through a binary tree, in Java? 
Java :: declare array with values java 
Java :: android activity read intent extra 
Java :: euclids algoritm java gcd 
Java :: char array to arraylist java 
Java :: android date 
Java :: java change text on click 
Java :: java iterate over list 
Java :: enum to int java 
Java :: how to do the maximum of three numbers in java 
Java :: java add button 
Java :: java arithmetic operators 
Java :: java logger 
Java :: printing prime numbers in java 
Java :: android studio pass value to another activity 
Java :: java printf trailing whitespace 
Java :: java gridpane background color 
Java :: java loop over string 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =