Android.support.v7.widget.recyclerview$viewholder.mitemviewtype ' on a null: Null pointer problem, the difficulty of finding the reason to report a null pointer:
The code is like this, with multiple layout types
@Override Public intGetitemviewtype (intposition) {Bmobimmessage message= Msgs.Get(position); if(Message.getmsgtype (). Equals (BmobIMMessageType.IMAGE.getType ())) {returnMessage.getfromid (). Equals (Currentuid)?Type_send_image:type_receiver_image; }Else if(Message.getmsgtype (). Equals (BmobIMMessageType.LOCATION.getType ())) {returnMessage.getfromid (). Equals (Currentuid)?type_send_location:type_receiver_location; }Else if(Message.getmsgtype (). Equals (BmobIMMessageType.VOICE.getType ())) {returnMessage.getfromid (). Equals (Currentuid)?Type_send_voice:type_receiver_voice; }Else if(Message.getmsgtype (). Equals (BmobIMMessageType.TEXT.getType ())) {returnMessage.getfromid (). Equals (Currentuid)?Type_send_txt:type_receiver_txt; }Else if(Message.getmsgtype (). Equals (BmobIMMessageType.VIDEO.getType ())) {returnMessage.getfromid (). Equals (Currentuid)?Type_send_video:type_receiver_video; }Else if(Message.getmsgtype (). Equals ("Agree")) {//Show Welcome returnType_agree; }Else{//return-1; returnType_agree; }
And then this is
GetItemCount ()
@Override Public int GetItemCount () { return msgs.size ();}
The last discovery was caused by the mismatch between ItemCount and ViewType.
For example:
There are 6 types of recyclerview, and now only one type test is written, the others are not, leading to an empty report, then return 1 in GetItemCount; It's OK.
int Android.support.v7.widget.recyclerview$viewholder.mitemviewtype ' on a null ....