gpt4 book ai didi

java - 如何访问字符串数组?(Android)

转载 作者:行者123 更新时间:2023-12-02 06:31:35 25 4
gpt4 key购买 nike

我是一名Android 开发新手。我想知道如何访问 string 数组 string.xml 并使用它。我在互联网上翻来覆去,一无所获。我找到了立即将其放入 TextView 的方法,但这不是我想要做的。所以,基本上,我想将字符串数组放入另一个数组string.xml:

<?xml version="1.0" encoding="utf-8"?>

<resources>
<string-array name="Solar System">
<item>Sun</item>
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
<item>Jupiter</item>
<item>Saturn</item>
<item>Uranus</item>
<item>Neptune</item>

所以我想把这个xml字符串数组转换成java字符串数组

感谢您的积极帮助,抱歉,我认为你们许多人所展示的方法不起作用。这只是我的程序中的另一个错误。

-谢谢

最佳答案

使用下面的

String[] planets = getResources().getStringArray(R.array.Planets);

关于java - 如何访问字符串数组?(Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20014694/

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