android - getItem(position) returns same object for different values of position -


i have adapter following piece of (test) code in public view getview(int position, view convertview, viewgroup parent):

    cursor itemcursor = (cursor) getitem(position);     cursor itemcursor2 = (cursor) getitem(position+1);      string itemtitle = itemcursor.getstring(itemcursor             .getcolumnindex(itemcolumns.title));     string itemtitle2 = itemcursor2.getstring(itemcursor2             .getcolumnindex(itemcolumns.title)); 

i override "dragsortcursoradapter" getitem() overridden this:

@override public object getitem(int position) {     int item = mlistmapping.get(position, position);     return super.getitem(item);     //return super.getitem(position); } 

the getitem called here normal implementation "android.support.v4.widget.cursoradapter.getitem"

the problem itemcursor , itemcursor2 same object. same object id , - have no idea how possible since getitem called different arguments, , list output screen shows different values.

in other words, when adapter iterates list seems this:

first list item:

cursor itemcursor = (cursor) getitem(0); cursor itemcursor2 = (cursor) getitem(0+1); 

itemcursor , itemcursor2 both 413d4800

second list item:

cursor itemcursor = (cursor) getitem(1); cursor itemcursor2 = (cursor) getitem(1+1); 

itemcursor , itemcursor2 both 4155aef8

shouldn't @ least itemcursor2 first iteration , itemcursor2 second iteration identical?

in case - can please me going on here? both have type "android.content.contentresolver$cursorwrapperinner@4155aef8" may or may not relevant - i'm not sure.

edit overridden getitem() working. mlistmapping.get(position, position); returns correct value , item indeed 2 different numbers - returning same object.

the problem itemcursor , itemcursor2 same object.

correct.

i have no idea how possible since getitem called different arguments

lots of methods can return same value given different arguments.

a cursoradapter wraps cursor. getitem() always return cursor. however, getitem() position internal index of cursor specified position. hence, while cursor same object, cursor returns methods getstring() differ, because internal position within cursor different.

you can see in action examining getitem() in the cursoradapter source code.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -