janki janki - 1 year ago 99
Android Question

split value and add in to spinner

want to add pipeline seprated value in to spinner.
I have String defined below.

String value =

how to split this value and add it in to spinner.

Answer Source

You can use the split method to do that:

String values = "12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35";
//to seperate by pipeline
String[] separatedValues = values.split("|");
//to seperate each character individually
String[] separatedValues = values.split("(?!^)")

ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(YourActivity.this, android.R.layout.simple_spinner_item, separatedValues);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download