StupidBeauty
Read times:691Posted at:Thu Feb 28 18:36:28 2013
- no title specified

转载 textView.setText(R.string.result+ result);的显示问题【已解决】

TextView.setText方法是重载的,既可传入 String类型的参数也可传入int类型的参数 这就使得 当妳要将 一个R.string.something与别的字符串连接起来之后 再传入 TextView.setText方法时,参数 会被当成整数处理,于是,显示出来的是一长串数字。解决办法 是将R.string.something使用getString方法包裹起来

http://www.eoeandroid.com/thread-53042-1-1.html

亮点

R.string.result是一个INT型的资源ID, 所以R.string.result+result还是一个INT型,而这INT型ID的资源是不存在的,textView.setText()可以是 textView.setText(string str)和textView.setText(int id),当ID资源不存在时,ID会toString()转换为字符串,故相当于调用了textView.setText(string str);
你应该这样:textView.setText(this.getString(R.string.result) + result);

袁洁莹

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4