在使用ArrayAdapter时使用自己写的R.layout.list_item布局容易出现:ArrayAdapter requires the resource ID to be a TextView 报错
R.layout.list_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView android:id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
xmlns:android=http://schemas.android.com/apk/res/android 就是这句了....
添加到自己的TextView中就ok.
因为根节点必须是TextView
修改后的list_item.xml
[java] view plaincopyprint?
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
分享到:
相关推荐
RecyclerView doesn't ship a ready to go RecyclerView.Adapter implementation as ListView did with the ArrayAdapter. This library is this missing ArrayAdapter. Easy to use Familiar API known from ...
ArrayAdapter 源码
演示如何使用定制的ArrayAdapter Android中的定制ArrayAdapter示例这个应用程序演示如何创建和使用自定义ArrayAdapter来显示自定义列表项视图,该视图比标准ArrayAdapter所支持的单个TextView更复杂。在这个例子中,...
ArrayAdapter各种详细的API解释!
ListView使用ArrayAdapter适配器源码
ArrayAdapter的基础使用,简单示例,适合初学者参考
ArrayAdapter和SimpleAdapter使用,详细了解请移步http://blog.csdn.net/zxc514257857/article/details/70217422
028_android UI组件之 ListView和ArrayAdapter,很细致的视频教程,这个可以学哦。
ArrayAdapter和BaseAdapter的区别是什么
简单使用ArrayAdapter
一个arrayadapter的demo,不是书上的那套,是自己写的,希望能给大家带来帮助
ArrayAdapter和simpleAdapter的回顾,好长时间都没有写android了,今天出来溜溜,这个写的是最初的功能。 就是listview。simpleAdapter是左图片右文本、 这个适合初学者玩下。
关于ArrayAdapter的几中适配样式,包括单选,多选和全选
ArrayAdapter和SimpleAdapter是适配器的两种。ListView控件是最常用的控件之一,ListView的经常使用ArrayAdapter和SimpleAdapter来加载数据源。ArrayAdapter(数组适配器)用作展现简单的纯文字列表;SimpleAdapter...
这是重写的继承自ArrayAdapter类的自定义适配器方式,数组元素是自定义类。对应的我的博客地址是:http://blog.csdn.net/u012320459/article/details/47667869
Android中使用ArrayAdapter的demo,比较简单,里面用两种方法实现,在MainActivity里面,其中一种被我注释起来了,大家把注释去掉就好了。没有使用自定义适配器,对应的我的博客地址是:...
如何借助ArrayAdapter和Spinner实现下拉列表.zip,欢迎下载!
安卓Android源码——(列表之ArrayAdapter适配).zip
安卓Android源码——(列表ArrayAdapter适配).zip
Android开发教程_019_创建一个ArrayAdapter_标清