Android学习--小白易错--TextView
来源:互联网 发布:阿里妈妈数据采集 编辑:程序博客网 时间:2024/06/02 21:54
TextView的setText()方法在设值时,要注意,形参的类型。下面是对一个用于显示数值的TextView设值时,没有转成String类型,导致出错。
public final void setText(int resid)
Since: API Level 1
public final void setText(int resid, TextView.BufferType type)
Since: API Level 1
public final void setText(char[] text, int start, int len)
Since: API Level 1
Sets the TextView to display the specified slice of the specified char array. You must promise that you will not change the contents of the array except for right before another call to setText(), since the TextView has no way to know that the text has changed and that it needs to invalidate and re-layout.
public void setText(CharSequence text, TextView.BufferType type)
Since: API Level 1
Sets the text that this TextView is to display (see setText(CharSequence)
) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.
Related XML Attributes
- android:text
- android:bufferType
public final void setText(CharSequence text)
SpannableString
, or see the Available Resource Types documentation for an example of setting formatted text in the XML resource file.11-05 10:53:43.780: E/AndroidRuntime(21035): FATAL EXCEPTION: main
11-05 10:53:43.780: E/AndroidRuntime(21035): android.content.res.Resources$NotFoundException: String resource ID #0x191b
11-05 10:53:43.780: E/AndroidRuntime(21035): at android.content.res.Resources.getText(Resources.java:252)
11-05 10:53:43.780: E/AndroidRuntime(21035): at android.content.res.MiuiResources.getText(MiuiResources.java:125)
11-05 10:53:43.780: E/AndroidRuntime(21035): at android.widget.TextView.setText(TextView.java:3642)
11-05 10:53:43.780: E/AndroidRuntime(21035): at com.example.neteasedemo.MainActivity$MyAdapter.getView(MainActivity.java:186)
0 0
- Android学习--小白易错--TextView
- android学习之TextView
- android:textview学习记录
- Android TextView学习
- Android学习笔记之TextView
- Android学习笔记之TextView
- Android开发学习--TextView 上
- Android学习--TextView和Button
- Android学习笔记-3-TextView
- Android之TextView控件学习
- Android控件TextView学习一
- Android控件TextView学习一
- Android 学习控件1-TextView
- Android UI学习之TextView
- Android基本控件TextView学习
- 【Android基础学习】TextView参数设置
- Android学习篇:TextView用法
- Android学习路之TextView
- javaEE 7 +tomcat7.0.54 webSocket +html5
- VC TreeCtrl 添加图标 背景色透明
- C++中的vector使用范例
- VS2010在设置为Release后出现的字符集问题
- Binary XML file line #13: Duplicate id 0x7f070055, tag null, or parent id 0x7f070054 with another fr
- Android学习--小白易错--TextView
- Java现场信息获取蛋疼方法
- GLSL. 语法基础
- MVC 用户权限过滤器。
- java.lang.NoSuchMethodError: ognl.SimpleNode.isEvalChain(Lognl/OgnlContext;)Z解决方法
- 高仿新闻教程——请求网络数据加入新闻内容页(11)
- 高可用浅谈
- Nginx 性能调优
- string字符串常用操作