android on recyclerview array bounds problems of

Problem Description: I have an array of cross-border issues is click the Delete operation appears at Recyclerview

I wrote several solutions: You can compare which is better 

                                                         The first

Index positon normal operation is determined if the index position is greater than the length of a list let the length minus, if the index is less than or equal to let the subscript 0 is equal to 0;

But this writing is still a small problem is that you normally delete is no problem to delete or 0 will be reported when an array bounds exception of 0,0

Analyze the reasons to me because I delete the first 0 when the method call activity is activty.removes (0);

This time because your list so there has been no data will be reported this error.

At this time I solve this problem: Think about this issue is how this occurs is because the list which has led us to 0 to determine what to make list (isEmpty!) Operation

This on it.

Array bounds exception occurs because we all know that, so I'll just say how to solve.

Published 15 original articles · won praise 0 · Views 5407

Guess you like

Origin blog.csdn.net/hc5054/article/details/88722072