last day (14 days later) » 

1:33 PM
0
A: Add more button inside recyclerView

tiny sunlight @Override public int getItemCount() { if (hasLoadButton) { return arrayList==null? 1 :arrayList.size() + 1; } else { return arrayList==null? 0 :arrayList.size(); } } if(position >= (arrayList==null? 0 :arrayList.size())) { tr...

 
I tried that too. I get an java.lang.IndexOutOfBoundsException: Invalid index exception
 
Change getItemCount in onBindViewHolder to (arrayList==null? 0 :arrayList.size()).
 
Now I get an attempt to invoke setonClickListener on a null object, because I'm not setting it in the right way in the holder. Let me try to modify and post back in 5 minutes. I think I know how.
I also updated with the holder if I can't do it
Changed it and I still get the null reference on the button
 
Try remove if(ViewType == IMAGES) in Holder first.And use try-catch to wrap mainHolder.addPhoto.setOnClickListener.
 
I had it without that before the edit and I would still get the same error
 
1:33 PM
Try to use try-catch to wrap mainHolder.addPhoto.setOnClickListener and log the position when the error occours.
 
I did. I get this java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
 
What's the position?
 
Inside the adapter. There is only one there, if that s what you meant
 
Add log in catch.
 
The message that I posted I get from the try catch block that is around mainHolder.addPhoto.setonclick...
 
1:33 PM
public void onBindViewHolder(SelectPhotoHolder holder, int position (I mean this position)) .
 
Oh, I'm sorry. It s The position is: 4. It's exactly where the button is supposed to be. I have 4 images and the button.
 
Can you try to create a ReyclerView only contains buttons to comfirm if the SelectPhotoHolder is right?
 

last day (14 days later) »