As I am new to android development i struck up with a problem where i am unable to set data to spinner adapter..
Here i am getting data from database is like
String times = [09:30,10:30,12:15,04:45,10:50] I am getting array in this pattern. When i am trying to set this array to spinner adapter it's getting error...
dateadp=new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_dropdown_item,times); datespn.setAdapter(dateadp);
so how to convert the following array to string array and how i can append that data to spinner. Can anyone help me with this....
["09:30","10:30","12:15","04:45","10:50"] represents String abc.
Then you can take following approach.
String processingString = abc.substring(abc.indexOf("[") + 1, abc.indexOf("]")); String arr = processingString.split(","); ArrayAdapter < String > adapter = new ArrayAdapter < String > (this, android.R.layout.simple_list_item_1, arr);