Hi,
 
Thanks for the suggestion.  I was aware of difference between checked and 
'coloured' and had tried the example you suggested.  That same example is 
in the APIDemos but it in itself has a bug if you rotate at the wrong time, 
it gets the highlight mixed up.  As I said above, I've mostly got it 
working from the SessionsFragment example from the IOSCHED12 Google app.
 

On Thursday, November 8, 2012 6:42:41 AM UTC-6, Kostya Vasilyev wrote:

> To answer your question number 2: 
>
> The highlighting is called "activated background" and is logically 
> different from "checked item, one of possibly several to perform actions 
> on".
>
> Marking an item "checked", at least with your MODAL selection mode, will 
> start the action mode, that's just how it works by design.
>
> So either don't use MODAL in your list view (as Mark already suggested), 
> or don't treat item selection and item activation (wrt. the background in a 
> master/detail layout) as being logically identical. They are not.
>
> I remember seeing bits of code to highlight / activate list items in one 
> of the early fragment samples (which accompanied a write-up by Dianne 
> Hackborn), it had quotes from Shakespeare's plays in it.... if this 
> helps....
>
> -- K
>
> 2012/11/1 Jim Stewart 
>
>> In portrait mode I have one Fragment List View (A).  When I click on the 
>> item it launches a new activity which in turn loads a new fragment (B) to 
>> display the selected record.  When I 'LongHold' on one item in (A) the CAB 
>> launches where I then 'Single Click' on lines to add/subtract lines to the 
>> 'Number of Selected' and have an option to delete.  All is good in this 
>> mode.
>>
>> In landscape mode I have something similar working except the 'B' 
>> fragment is launched in its own Frame so it appears alongside the list 
>> fragment (A).
>>
>> The problem I am having is trying to 'highlight' the item I picked from 
>> the list (A) for the details being displayed (B).
>>
>>     public void onListItemClick(ListView l, View v, int position, long 
>> id) {
>>     super.onListItemClick(l, v, position, id);
>>     mListener.displayMarkers(id);
>>                 getListView().setItemChecked(position, true);
>>     }
>>
>> As soon as I setItemChecked the Contextual action bar launches.  I only 
>> want the Contextual action bar to launch on the initial 'long click' same 
>> as it does in portrait mode.
>>
>> I checked how Google are doing this and in GMAIL inbox landscape on a 
>> tablet, single click highlights the item in the list and displays the email 
>> in the detail 'frame'. a 'long click' launches the CAB for the line you 
>> selected. You can continue to single click on lines to see the details but 
>> you 'long click' to add items to the CAB.  Interestingly the cell 
>> background is different based on whether it is selected or long clicked in 
>> the CAB.
>>
>> The contextual action bar is configured as follows
>>
>>     getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
>>     getListView().setMultiChoiceModeListener(multiChoiceModeListener);
>>
>> The code for the multiCoiceModeListener is as follows
>>
>> MultiChoiceModeListener multiChoiceModeListener = new 
>> MultiChoiceModeListener() {
>>
>> @Override
>> public void onItemCheckedStateChanged(ActionMode mode, int position,
>> long id, boolean checked) {
>> mListener.removeFragmentWhenCABStarted();
>> if (checked) {
>> ++mNumberOfSelectedItems;
>> } else {
>> --mNumberOfSelectedItems;
>> }
>> // Refresh the menu - Edit is only available when one item is
>> // selected
>> mode.invalidate();
>> mode.setTitle(String.valueOf(mNumberOfSelectedItems) + " selected");
>> }
>>
>> @Override
>> public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
>> // Respond to clicks on the actions in the CAB
>> switch (item.getItemId()) {
>> case R.id.menu_delete:
>> confirmDelete();
>> return true;
>> case R.id.menu_edit:
>> edit();
>> return true;
>> default:
>> return false;
>> }
>> }
>>
>> @Override
>> public boolean onCreateActionMode(ActionMode mode, Menu menu) {
>> // Inflate the menu for the CAB
>> MenuInflater inflater = mode.getMenuInflater();
>> inflater.inflate(R.menu.main_fragment_context_menu, menu);
>> mode.setTitle(String.valueOf(mNumberOfSelectedItems) + " selected");
>> mActionMode = mode;
>> return true;
>> }
>>
>> @Override
>> public void onDestroyActionMode(ActionMode mode) {
>> mNumberOfSelectedItems = 0;
>> }
>>
>> @Override
>> public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
>> menu.findItem(R.id.menu_delete).setVisible(true);
>> menu.findItem(R.id.menu_edit).setVisible(true);
>> if (mNumberOfSelectedItems > 1) {
>> menu.findItem(R.id.menu_edit).setVisible(false);
>> }
>> return true;
>> }
>> };
>>
>>  
>>
>> So to the questions.
>>
>> 1. How would you control the CAB based on Long Holds the way Google are 
>> doing it?
>> 2. How can I select a line (or change its background) without launching 
>> the CAB?
>> 3. Am I over thinking this and you have a much easier solution
>>
>> Any assistance would be appreciated.
>>
>> Thanks,
>>
>> Jim
>>
>>  
>>  
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to 
>> android-d...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com <javascript:>
>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to