如何解决ArrayAdapter requires the resource ID to be a TextView
来源:互联网 发布:一个淘宝网站值多少钱 编辑:程序博客网 时间:2024/05/18 02:16
今天碰到这样一个难题,高了很久都没搞定,到网上搜索了一下,发现有很多人都在问这样的问题,现在将自己解决很分析的结果放置如下:
在arrayadapter()这个类中有多个构造方法,我仅据此列以作代表
public ArrayAdapter(Context context ,int textViewResourceId ,List<T> objects)
Constructor
参数:
context ----》 The current context
textViewResourceId ---->the resource ID for a layout file contain a TextView to use when instantiating views.
List<T> objects ---> the objects to represent in the ListView
第一个参数自不必说,上下文
第二个参数的意思是说 当装载在这个构造函数中的layout 时,其layout的ID 必须是一个TextView,简言之,第2个参数应该是ListView中每个选择项的样式,可以使用系统自带的android.R.layout.xxx,也可以是自定义的,仅包含TextView。
第三个参数也不必说了
那么解决这个问题的时候,你的main.xml要更改为:
<?xml version="1.0" encoding="utf-8"?>
<TextViewxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
因为根节点必须是TextView,不然就会抛“ArrayAdapter requires the resource ID to be a TextView”
- 如何解决ArrayAdapter requires the resource ID to be a TextView
- ArrayAdapter requires the resource ID to be a TextView问题
- ArrayAdapter requires the resource ID to be a TextView问题
- ArrayAdapter requires the resource ID to be a TextView问题
- ArrayAdapter requires the resource ID to be a TextView 错误
- ArrayAdapter requires the resource ID to be a TextView问题
- Q: ArrayAdapter requires the resource ID to be a TextView
- ArrayAdapter requires the resource ID to be a TextView问题
- ArrayAdapter requires the resource id to be a TextView
- ArrayAdapter requires the resource ID to be a TextView错误
- ArrayAdapter requires the resource ID to be a TextView 的解决办法
- 关于出现 ArrayAdapter requires the resource ID to be a TextView问题
- ArrayAdapter requires the resource ID to be a TextView问题整理
- 报错:ArrayAdapter requires the resource ID to be a TextView
- 解决 Android Nougat requires the IDE to be running with Java 1.8 or later Install a supported JDK
- “The resource could not be loaded because the App Transport Security policy requires the use of a se
- The resource could not be loaded because the App Transport Security policy requires the use of a sec
- The resource could not be loaded because the App Transport Security policy requires the use of a sec
- 相对布局:使用相对布局实现如下界面的设计
- asp.net动态切换主题
- iOS7死机率比安卓高2倍!爱疯5S冲进3K档
- C语言基础系列--运算符
- Nyoj 737 石子合并(一)
- 如何解决ArrayAdapter requires the resource ID to be a TextView
- 滚动时自动加载内容
- php如何混合匹配中文数字字母
- XML基础
- web项目开发流程经验总结
- CString+nChar的问题
- 有源晶振和无源晶振的区别
- USACO打怪升级(一):What is USACO?
- n位段高x低n-x位的存储与分组(移位 逻辑运算符的妙用)