Basically I need to toast a message written in Chinese t开发者_JAVA百科o user. However I don't know how to achieve such thing. Any solution that can help me?
I'm not an Android programmer, but doesn't this work?
Context context = getApplicationContext();
CharSequence text = "中国的网页";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
Code ripped from here.
(Apologies if that means anything offensive. I simply ripped some random characters from here).
I found my own answer. It's so simple I didn't think of that in the first place. And it always works. Under res/values/string.xml of Android project, I edit:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="sample">中国的网页</string>
</resources>
And the I retrieve the string name "sample" out of project's resource using:
this.getString(R.string.sample);
精彩评论