gpt4 book ai didi

Android 将 R.String.xx 值传递给字符串生成器

转载 作者:太空狗 更新时间:2023-10-29 16:16:16 25 4
gpt4 key购买 nike

字符串生成器的字符串值,但我无法获取该值

builder.append("<tr align=center bgcolor=#9d8a2e><th colspan=2 height="
+ tableHeight
+ " width="
+ tableWidthLeft
+ **R.string.useonly**
+ "</th><th align=right height="
+ tableHeight
+ " width="
+ tableWidthRight
+ ">"
+ Provider.im_rad + "" + "</th></tr>");

我想通过 R.string.useonly 但它不工作......但是当我按照下面的方式这样做时它正在工作

builder.append("<tr align=center bgcolor=#9d8a2e><th colspan=2 height="
+ tableHeight
+ " width="
+ tableWidthLeft
+ ">for use only purpose"
+ "</th><th align=right height="
+ tableHeight
+ " width="
+ tableWidthRight
+ ">"
+ Provider.im_rad+ "" + "</th></tr>");

最佳答案

要获取你应该使用的字符串资源

getResources().getString(R.string.your_text); 

如果你在 fragment 上调用它,你应该在开头添加 getActivity()

关于Android 将 R.String.xx 值传递给字符串生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26256584/

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