int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null.....

书史足自悦,安用勤与劬。这篇文章主要讲述int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null.....相关的知识,希望能为你提供帮助。
Android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType‘ on a null..空指针问题,费劲心思才找到报空指针的原因:
代码是这样的,有多种布局类型
 

@Override public int getItemViewType(int position) { BmobIMMessage message = msgs.get(position); if(message.getMsgType().equals(BmobIMMessageType.IMAGE.getType())){ return message.getFromId().equals(currentUid) ? TYPE_SEND_IMAGE: TYPE_RECEIVER_IMAGE; }else if(message.getMsgType().equals(BmobIMMessageType.LOCATION.getType())){ return message.getFromId().equals(currentUid) ? TYPE_SEND_LOCATION: TYPE_RECEIVER_LOCATION; }else if(message.getMsgType().equals(BmobIMMessageType.VOICE.getType())){ return message.getFromId().equals(currentUid) ? TYPE_SEND_VOICE: TYPE_RECEIVER_VOICE; }else if(message.getMsgType().equals(BmobIMMessageType.TEXT.getType())){ return message.getFromId().equals(currentUid) ? TYPE_SEND_TXT: TYPE_RECEIVER_TXT; }else if(message.getMsgType().equals(BmobIMMessageType.VIDEO.getType())){ return message.getFromId().equals(currentUid) ? TYPE_SEND_VIDEO: TYPE_RECEIVER_VIDEO; }else if(message.getMsgType().equals("agree")) {//显示欢迎 return TYPE_AGREE; }else{ //return -1; returnTYPE_AGREE; }

然后这是
getItemCount()

@Override public int getItemCount() { return msgs.size(); }

最后发现是因为itemCount与viewType不匹配导致的
例如:
recyclerview总共有6种类型,现在只写了一种类型测试,其他的都没有些,才导致报空,然后在getItemCount中return 1;   就ok了
【int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null.....】 

    推荐阅读