Is it possible to use a hashmap in ArrayAdapter instanciation ?
my "regions" hashmap handles custom ID as keys : Hashmap<ID,Value>
.
vRegions.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simp开发者_Python百科le_list_item_1, regions));
the problem here is that ArrayAdapter
will call my hashmap's toString()
which will print value
and discard ID
!
I want to be able to use that ID , is there any way to set it as simple_list_item_1
's ID
so i can retreive it later inside onclick event?
I would extend ArrayAdapter
and add the logic there.
Solved this by passing a hashmap
to my ArrayAdapter
where keys are texts and values are the IDs.
I use the pressed item position to get the text then i search my hashmap
for the associated ID.
精彩评论