addView(View, LayoutParams) is not supported in AdapterView异常
来源:互联网 发布:什么是it管理 编辑:程序博客网 时间:2024/06/05 07:59
错误如下:
所以,只好乖乖地把这个类中需要复写的方法全部实现后,问题解决
java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
原因分析与解决办法:
在使用AdapterView时,往往遇到getView函数,而该函数有一个Parent的参数,也就是父容器:
public View getView(int position, View convertView, ViewGroup parent)那么,什么时候需要把新生成的View连接到parent?
据我所知,ArrayAdapter和BaseAdapter,SimpleAdapter都是不支持的,因此该参数应传入null,否则就会报上面的异常
另外,在下面的代码段中,
public View getView(int position, View convertView, ViewGroup parent) {Record record = mRecords.get(position);if (convertView == null) {convertView = mInflater.inflate(R.layout.record_list_item,null);holder = new ViewHolder();holder.chipView = convertView.findViewById(R.id.chip);holder.carView = (TextView) convertView.findViewById(R.id.carnumber);holder.dateView= (TextView) convertView.findViewById(R.id.date);holder.statusView = (TextView) convertView.findViewById(R.id.status);holder.subjectView = (TextView) convertView.findViewById(R.id.subject);holder.selectedView = (ImageView) convertView.findViewById(R.id.selected);convertView.setTag(holder);} else {holder = (ViewHolder) convertView.getTag();}
convertView = mInflater.inflate(R.layout.record_list_item,null);inflate函数的第一个参数ResourceID,也需要特别注意。由于我这里使用的record_list_item.xml是自定义的一个组件,继承自RelativeLayout,但是并没有具体写东西,仅为了测试使用,但运行时抛出异常:
android.view.InflateException: Binary XML file line #12: Error inflating class
所以,只好乖乖地把这个类中需要复写的方法全部实现后,问题解决
不过网上也有说这个错误时因为图片加载问题,点这里查看详情
END
- addView(View, LayoutParams) is not supported in AdapterView异常
- addView(View, LayoutParams) is not supported in AdapterView
- [Android界面] addView(View, LayoutParams) is not supported in AdapterView
- addView(View, LayoutParams) is not supported in AdapterView
- java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- Android开发:UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- ListView adapter getView 报错: addView(View, LayoutParams) is not supported in AdapterView
- java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
- Android开发:UnsupportedOperationException: addView(View, LayoutParams) is not supported in ...
- UnsupportedOperationException: addView(View, LayoutParams) is not supported in ...
- Unable to start activity:UnsupportedOperationException: addView(View, LayoutParams) is not supported
- View[6] inflate()、addView()removeView() 及 LayoutParams
- hadoop异常: Operation category READ is not supported in state standby
- Is index important in addView()?
- 异常:java.net.SocketException: Method sendUrgentData() is not supported
- ssl is not supported
- MFC表格控件的简单使用
- C#线程篇---让你知道什么是线程(1)
- 策略模式
- 最近的状态好混乱
- jQuery调用WCF需要注意的一些问题
- addView(View, LayoutParams) is not supported in AdapterView异常
- 软件开发比较齐全的帮助文档
- jquery调WCF
- Java实现的几个常用排序算法详细解读
- 将Eclipse中的Web项目部署到Tomcat
- Documentum 中编号标识和type类型的对应关系表(基础)
- 关于用U盘安装win7提示加载驱动程序的解决办法
- 学习 WCF (6)--学习调用WCF服务的各种方法
- export_symbol的使用