Yes, I did and this causes the Multiselect mode CAB to show up. CAB shows up as 
soon as 
setItemChecked is called programmatically if CHOICE_MODE_MULTIPLE_MODAL is set 
for the
listView.

Anyways I went ahead and created a custom ArrayAdapter which keeps all the 
state information about
selection, multiselect etc and then based on the state it does background color 
changes when getView
is called:

public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);

if (!bMultiSelect)
{
if (position == nSelectedPostion)
v.setBackgroundColor(nColor);
else
v.setBackgroundColor(Color.TRANSPARENT);
}
else
{
if (nSelectedPositions[position] == 1)
v.setBackgroundColor(nMultiColor);
else
v.setBackgroundColor(Color.TRANSPARENT);
}
return v;
}




---
Take care,
Pankaj


On Thursday, September 6, 2012 at 1:34 PM, Calin Perebiceanu wrote:

> Did you tried handling the on list item click ?
> @Override
> protected void onListItemClick(ListView l, View v, int position, long id) {
> // Make the newly clicked item the currently selected one.
> getListView().setItemChecked(position, true);
> }
> 
> On Thursday, 6 September 2012 07:52:18 UTC+3, Pankaj Chawla wrote:
> > Hi 
> > 
> > So ListView has a item layout 'simple_list_item_activated_1' which when 
> > used with 
> > ListView.CHOICE_MODE_SINGLE causes the item to stay activated causing a 
> > background 
> > highlight. ApiDemos has a sample under Lists/List17. 
> > 
> > The same item layout when used with ListView.CHOICE_MODE_MULTIPLE_MODAL 
> > causes the item to highlighted when multiselect mode gets activated on 
> > longitemclick. ApiDemos 
> > again has a sample under Lists/List16. The problem here is that now on 
> > short press the item 
> > is not highlighted like in List17 but highlight only works when multiselect 
> > mode gets enabled 
> > on long press. 
> > 
> > So what I am trying to achieve is that item stays activated/hightlighted on 
> > short press/itemClick 
> > and also highlights when mutilselect mode gets enabled on long press. I 
> > tried playing around 
> > with List16 and List17 code to see if I can get the functionality to work 
> > but havent got it 
> > working. Any clues will be helpful. The Gmail app on tablet (Nexus 7) has 
> > this working where 
> > itemclick highlights the message row and longitemclick goes into 
> > mutliselect mode with selected 
> > rows highlighted. 
> > 
> > --- 
> > Take care, 
> > Pankaj 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected] 
> (mailto:[email protected])
> To unsubscribe from this group, send email to
> [email protected] 
> (mailto:[email protected])
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to