Ok, I did it and Now i am getting a Json array from server and converting it simply into Java Array to used for Spinner. here is the code for future reference.
JSONArray jsonArray = new JSONArray(json_string); List<String> items = new ArrayList<String>(); for (int i=0; i<jsonArray.length(); i++) { items.add( jsonArray.getString(i) ); } String [] anArrayOfStrings = new String[jsonArray.length()]; items.toArray(anArrayOfStrings); Now you can use this "items" array for your spinner. if some one need full code or detail let me know i will help you to do this. Now i have a Question, In my Database on Server side I want to fetch "id" [int] against the "Name" [String] which is displayed by spinner. Now when user will select the Name its relevant id should be selected which will be send back to the server along with additional data. Same like drop down list in html e.g <form name="myform" action="http://www.mydomain.com/myformhandler.cgi" method="POST"> <div align="center"> <select name="mydropdown"> <option value="10">Android</option> <option value="15">iphone</option> <option value="18">others</option> </select> </div> </form> How i can do this ? any idea or tutorial ? Atif On Mar 7, 8:59 pm, Atif Musaddaq <atif.musad...@gmail.com> wrote: > Hi, All > > I am fetching data from json to array list, code given below. > > JSONArray jsonArray = new JSONArray(json_string); > String[] anArrayOfStrings; > List<String> items = new ArrayList<String>(); > for (int i=0; i<jsonArray.length(); i++) { > items.add( jsonArray.getString(i) ); > > } > > Now all my data is in Array List "items" > > I would like to populate/generate Spinner out of this array List, How i will > do that. there are lot of examples available on the internet to create > Spinner with Arrays but not Array List. > > or How i can convert this Array List to normal Array OR How i can populate > an array using above for loop. > > I am beginner to android/java etc...................Help will be really > appreciated. Thanks in advance. > > -- > Atif Musaddaq -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en