gpt4 book ai didi

Android:获取字符串数组中使用的字符串资源的名称

转载 作者:数据小太阳 更新时间:2023-10-29 02:44:07 26 4
gpt4 key购买 nike

我有一个小问题。

My string.xml

<resources>
<!-- Months -->
<string name="january">January</string>
<string name="february">February</string>
<string name="march">March</string>
<string name="april">April</string>
<string name="may">May</string>
<string name="june">June</string>
<string name="july">July</string>
<string name="august">August</string>
<string name="september">September</string>
<string name="october">October</string>
<string name="november">November</string>
<string name="december">December</string>
</resources>

And my months.xml

<resources>
<string-array name="months">
<item>@string/january</item>
<item>@string/february</item>
<item>@string/march</item>
<item>@string/april</item>
<item>@string/may</item>
<item>@string/june</item>
<item>@string/july</item>
<item>@string/august</item>
<item>@string/september</item>
<item>@string/october</item>
<item>@string/november</item>
<item>@string/december</item>
</string-array>
</resources>

我为微调器设置了 months.xml。

<Spinner
android:id="@+id/sn_months"
android:layout_width="150dp"
android:layout_height="50dp"
android:textAlignment="center"
android:entries="@array/months"/>

现在,我想使用项目的位置在微调器的 onItemSelected 中获取项目的字符串名称,例如 january、february...不是 January、February...。我该怎么做?

最佳答案

public void onItemSelected(AdapterView<?> parent, View view, int pos,long id) {
String yearnam=parent.getItemAtPosition(pos).toString()toLowerCase();
}

关于Android:获取字符串数组中使用的字符串资源的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40022045/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com