R.string.value Help android notification

后端 未结 4 1152
粉色の甜心
粉色の甜心 2021-02-12 10:48

whats the deal with

 CharSequence contentTitle = R.string.value;

Error cannot convert from int to CharSequence. Is there a way around this or a

4条回答
  •  不思量自难忘°
    2021-02-12 11:05

    To retrieve the string, you need to use getString(),

    but getString() is a method from Context class. If you want to use this method outside your Activity class, you should get link to your context first and then call:

    String s = mContext.getString(R.string.somestring)
    

提交回复
热议问题