I have an enum class, but I want to display the string based on user system language. For example, if the system is English, then it should display 1, 2, 3. But if the system is Chinese, then the display should be completely different as "one", "二", "三". (AE means 1 in sugar, 二 means 2 in sugar).
This is my code
public audio order type {one ("1"), two ("2"), three ("3") private string name; Private order type (string name) {this.name = name; } Public string toString () {return name; } Public static string getEnumByString (string code) {for (order type e: order type value.) {If (code.equals (e.name)) {return e.name (); }} Return tap; }}
Anonymous works fine in Android, can I define a string in the value folder,
values such as iw, value-ru .. And how can I use it?
UPDATE: I also want to use the container to initialize the enum string. Like
private order type (string name) {string temp = miller resource (). GetString (R.string.name); This.name = temp; }
But I do not know that r. String How to pass parameters parameters. Second, how can I use the getResources () function in the enum class
public enum command type {a (mActivity.getString (R.string.One)), two (mActivity.getString (R. string.Two)); The name of the private string; Private order type (string name) {this.name = name; } Public string toString () {return name; } Public static string getEnumByString (string code) {for (order type e: order type value.) {If (code.equals (e.name)) {return e.name (); }} Return tap; }}
Also here, which I think is the best way to solve porblem It currently develops for API level 11, although this code should be run on higher versions. After a quick review in API 16, I did not find an existing core Android solution for this problem, if you know about one, then post and share below.
Comments
Post a Comment