When I use the android Studio compiler, I always encounter a lot of garbled problems. The first garbled problem is defined in the layout file inside the EditText, in the code need to get the content into the edittext inside, this time if there is a Chinese language will appear garbled, the code is as follows:
Super.oncreate (save); Setcontentview (R.layout.second); EditText show = (EditText) Findviewbyid (r.id.show); ComponentName comp = getintent (). Getcomponent (); Show.settext ("component package named" +comp.getpackagename () + "component class named" +comp.getclassname () ");
The result of the display is that the package name for these Chinese characters is garbled and cannot be displayed properly. A good solution is to put the text in the String.xml, in the code to refer to it, the code is as follows:
Show.settext (GetString (r.string. The component package is named +comp.getpackagename () +getstring (r.string. The component class name is ) +comp.getclassname ());
This solution for less Chinese, is very convenient and fast, can avoid a lot of garbled problems.
Many also have comments on the Chinese code, in the lead from others, the general will appear garbled problem, this time, for the running code location, click on the lower right of the code conversion, converted to UTF-8 format, generally can solve the problem.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Studio solves SetText Chinese garbled problem