error
String literal in setText can not be translated. Use Android resources instead.
Cause of
When the TextView object refers to the setText method, the string is directly passed in.
Example
TextView textView = new TextView(this);
textView.setText("text"); // Error: String literal in setText can not be translated. Use Android resources instead.
【Solution】
1. Add strings to the strings.xml file in the values folder in the res folder.
<resources>
<string name="txtText">text</string>
</resources>
2. When the TextView object references the setText method, pass in the getString method.
TextView textView = new TextView(this);
textView.setText(getString(R.string.txtText));
Read More:
- Testlink 1.9.16 Error: Fatal error: Uncaught Error: Cannot use string offset as an array in D:\softe
- [Solved] kubeflow pipeline visualization component Error: WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager…
- Chart.js Error: “Canvas is already in use. Chart …must be destroyed before the canvas can be reused”
- Error reported with decorator in vue: Parsing error: Decorators cannot be used to decorate object literal properties
- [Solved] Android Error: AAPT: error: unescaped apostrophe in string;Multiple substitutions specified in non-positi
- Runtime error prompt in Android Studio: arrayadapter requires the resource ID to be a textview problem
- [Solved] Failed to install the following Android SDK packages as some licences have not been accepted
- [Solved] Android Studio Compile error: Cannot use connection to Gradle distribution . as it has been stopped.
- JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token
- [Go] Solve the empty interface interface{} cannot use (type []string) as type []interface {}
- [Solved] OpenCV ERROR: The minSdk version should not be declared in the android manifest file
- The SDK of Android webrtc compiled with Ninja – C out / release command reported an error, and the Android NDK processing method could not be found
- The showdialog() method in thread/threading. Timer/task reported an error: “before ole can be called, the current thread must be set to single thread unit (STA) mode.”
- Git under Windows reports an error: warning: LF will be replaced by CRLF in ××××.××
- [Solved] void value not ignored as it ought to be
- [Solved] Springboot WARNING: All illegal access operations will be denied in a future release
- [Solved] ViewBinding Error: java.lang.ClassCastException: android.widget.RelativeLayout cannot be
- Android studio can’t start, running error: warning: crash service did not start
- [Solved] swiper Error: The requested module ‘react’ is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export
- [Solved] Android12 Download Error: The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED