How to display data in spinner from json

Posted by user1605913 on Stack Overflow See other posts from Stack Overflow or by user1605913
Published on 2012-08-27T09:45:59Z Indexed on 2012/08/28 3:38 UTC
Read the original article Hit count: 210

Filed under:
|
|
|

I am retrieving values from a json url and then storing it in a string variable. Now I want to display that value in a spinner. I have created an array list in my strings.xml file. The xml file contains following code:

<string name="credit_card_title">Card Type</string>
<string-array name="credit_card">
<item >Select</item>
<item >Visa</item>
<item >MC</item>
<item >Amex</item>
<item >Discover</item>

my spinner code is:

<Spinner
android:id="@+id/crdtcrd_crdtype"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/credit_card"
android:prompt="@string/credit_card_title" />

After retriving the value from the json url I am storing it in variable name String cardtype

Now how can I display the value of cardtype in the Spinner crtdcrd_crdtype....

the json url is:

http://mygogolfteetime.com/iphone/login/[email protected]/123456

From this URL I have to retrieve the value of cardtype and after retrieving the value i have to display it in the spinner..

There are different values for cardype like visa, mc, amex and discover All these values are in my strings.xml file and after retrieving the value I have to display it in Spinner..

Help needed still not able to find the solution..

Thanks in advance...

© Stack Overflow or respective owner

Related posts about android

Related posts about JSON