Recently encountered a very wonderful problem the same code in two different phones present different status a Samsung mobile phone running smoothly no problem a domestic Lenovo mobile phone running out of bounds error
Looking for a long time may be wrong place in the adapter inside can go to low is where the cross-border?
I need to show 2 layouts in a ListView that need to return two values in the Getitemviewtype method at first a value of 1 (chat_come) and a 2 (chat_to) OK should have no problem,
Pay special attention to the wonderful rule of this method is that you must return a 0! But it's still a problem. On the Lenovo phone specifically reiterated on the Samsung Phone no problems
Got a look. Data found that the value returned in the Getitemviewtype method must be less than
The value returned by the Getviewtypecount Method!
That is, no matter how many layout definitions you need to load in the ListView, the type can only start with 0! This is exactly the same as the Getitemviewtype method must return a 0 rule combined on only starting from 0 count
The value of type is less than Getviewtypecount returned!
The number of two returned is then changed to 0 (Chat_come)
One change to 1 (chat_to)
The problem is solved.
What I don't understand is why there's no such problem on Samsung's phone? Test Machine Limited did not test the other domestic mobile phones will have the same phenomenon
Public int getitemviewtype (int position) {
TODO auto-generated Method stub
if (list. Get (position). Iscomemsg ()) {
return Common. Chat_come;
}Else
return Common. chat_to;
}
Android Baseadapter Java.lang.ArrayIndexOutOfBoundsException!!!!!!!!!