【发布时间】:2012-08-21 19:15:57
【问题描述】:
我正在从 json url 中检索值,然后将其存储在字符串变量中。现在我想在微调器中显示该值。我在我的 strings.xml 文件中创建了一个数组列表。 xml文件包含以下代码:
<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>
我的微调器代码是:
<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" />
从 json url 检索值后,我将其存储在变量名称 String cardtype
现在如何在 Spinner crtdcrd_crdtype 中显示 cardtype 的值....
json url 是:
http://mygogolfteetime.com/iphone/login/ramu@gmail.com/123456
从这个 URL 我必须检索 cardtype 的值,在检索到值后我必须在微调器中显示它..
cardype 有不同的值,例如 visa, mc, amex and discover
所有这些值都在我的strings.xml 文件中,在检索到值后,我必须在 Spinner 中显示它..
需要帮助仍然无法找到解决方案..
我正在尝试使用以下代码显示cardtype 的值:
crdtcrd_crdtype.setSelection(cardtype);
但它显示了一些错误.. 1.改为setSelected(..) 2.将cardtype的类型改为int
提前谢谢...
【问题讨论】:
标签: android json spinner android-spinner