• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps spinner with numbers

I need to use a spinner going from 4 to 100.
All I can find on the web is spinner and string array examples using ArrayAdapter.
Please help.
Claus
 
I've never used a spinner, but I'm sure theres a corresponding function for ints like there is to insert Strings into the spinner. If not, use Integer.toString(yourint); to convert the int into a String

Code:
for(int i =4; i<=100; i++) {
  // insert i into spinner
}
 
Here's my code:
//private constants
private static final int MIN = 4;
private static final int MAX = 100;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
(...)
//private Adapters for setting values to UI
String[] np = new String[MAX-MIN];
for(int i=MIN;i<=MAX;i++){
np[i-4]=Integer.toString(i);
}
ArrayAdapter <String> _aa = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,np);//array holding min and max pages
_spinner.setAdapter(_aa);
}
(...)
}
 
Back
Top Bottom