Android - view tag isn't correct on view:null
来源:互联网 发布:ubuntu下安装samba 编辑:程序博客网 时间:2024/06/09 14:09
看下面代码注意三点:
@Override public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 1.使用DataBindingUtil 实现 NewsFragmentPageItemBinding bind = DataBindingUtil .inflate(inflater,R.layout.news_fragment_page_item,parent,false); CustomViewHolder viewHolder=new CustomViewHolder(bind.getRoot()); return viewHolder; } @Override public void onBindViewHolder(CustomViewHolder holder, int position) { NewsCustom newsCustom = newsCustoms.get(position); 2.使用DataBindingUtil获得binding NewsFragmentPageItemBinding bind=DataBindingUtil.getBinding(holder.itemView); bind.setTitle(newsCustom.getTitle()); } @Override public int getItemCount() { return newsCustoms.size(); } static class CustomViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ public CustomViewHolder(View itemView) { super(itemView); 3.viewholder里也可以实现 NewsFragmentPageItemBinding binding = DataBindingUtil.getBinding(itemView); binding.ripple.setOnClickListener(this);//设置点击事件 } @Override public void onClick(View v) { } }
0 1
- Android - view tag isn't correct on view:null
- can't call void android.view.View.setElevation(float) on null obj in call to CallVoidMethodV
- android.view.View android.view.View.findViewById(int)' on a null object reference
- android.widget.LinearLayout.addView(android.view.View)' on a null object reference
- Attempt to invoke virtual method 'android.os.IBinder android.view.View.getWindowToken()' on a null o
- Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
- field 'int android.view.View.mViewFlags' on a null object reference
- Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
- Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null ob
- Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
- How to fix process system isn’t responding on Android?
- 用android view中的tag传送数据
- Android开发之View.setTag(Object tag)
- 在小米上面运行时的void android.view.View.setDrawingCacheBackgroundColor(int)' on a null object reference错误
- Android实现动画过程中遇到View.mViewFlags on null object refrence
- Android开发之~java.lang.ClassNotFoundException: Didn't find class "android.view.x" on path: ...
- View Tag 的使用
- View Tag 要注意
- 反射机制--获取实例化对象
- runtime 运行时机制 完全解读
- 画PCB
- What is EFF in BI
- 无法复制粘贴可以使用clip
- Android - view tag isn't correct on view:null
- SharedPreferencesUtil
- 理解 Objective-C Runtime
- HTML data-*属性
- myBatis将null作为参数传递报错问题
- pixhawk uORB初步分析
- kfaka架构介绍
- 剑指offer之面试题18树的子结构
- NYOJ 42 一笔画问题