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) sends long 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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -