What's the purpose of item-id's in Android ListView Adapter? -
(not specific listview, adapter).
i keep implementing when subclass baseadapter:
@override public long getitemid(int position) { return position; }
because have implement that. don't see use of it, need getitem(position) only, not getitemid(position).
i wonder if has significance (to android sdk or else)?
there many reasons have stable item ids. default implementation cannot given since depends on type of object being stored in adapter.
android has check make sure item ids used when stabled, i.e. subclass has overridden getitemid
; baseadapter.hasstableids must overriden return true.
few reasons have come across:
adapterview.onitemclicklistener's method
onitemclick(adapterview<?> parent, view view, int position, long id)
sendslong id
the getcheckeditemids method
the result valid if choice mode has not been set choice_mode_none , adapter has stable ids.
reply "because have implement that": don't have to if don't use features, there's no need. if do, don't forget override boolean hasstableids()
well.
Comments
Post a Comment