开发者

getString from strings.xml in AppWidgetProvider

开发者 https://www.devze.com 2023-04-04 04:46 出处:网络
I have this in a normal activity: tv.setText(this.getString(R.string.week1)); I think remoteViews.s开发者_如何学运维etTextViewText(R.id.widget_textview,\"something\");

I have this in a normal activity:

tv.setText(this.getString(R.string.week1));

I think

remoteViews.s开发者_如何学运维etTextViewText(R.id.widget_textview,"something");

is the equivalent to

tv.setText("something");

How do I getString from strings.xml in AppWidgetProvider?

There is probably a really easy solution but I tried using google and I'm new to android...


So, when you get a hold of a Context you can just call

context.getString(resIdHere);

onEnable(), onDisable(), onReceive() and onUpdate() methods all pass context reference in to their definitions by default.

Hope this helps,

-serkan


I do not know how to "How do I getString from strings.xml in AppWidgetProvider?" but I think you try to get string from strings.xml

and that could be done like this.

String s = getResources().getString(R.string.-yourString);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号