我在strings.xml文件上存储了一个URL,以在我的应用程序中显示它,它是这样的:
<string name="url_stat">https://my.websyte.net/url_stramin/api/v1/</string>
当我想在Java中使用它时,我这样称呼:
textView.setText(R.string.url_stat+"key/");
Log.i("KEY",R.string.url_stat+"key/");
但是我得到的是这段文字:
2131623976键/
由于某种原因,该字符串变成了数字,为什么?如何避免呢?
该数字是数字标识符(资源值),您应该执行以下操作
textview.setText(getString(R.string.api_stat) + "key/");