Today I spent several hours experimenting with custom ActionMode views.
First, I made something with menu items triggering custom dialogs. It was 
very rough so I decided to go with a custom layout.
I have noticed ActionMode.setCustomView(View) 
<http://developer.android.com/reference/android/support/v7/view/ActionMode.html#setCustomView(android.view.View)>.
 
The function itself is documented as it should but I've failed in finding a 
sample or example of how to use this functionality.

The main problem is I don't know how to inflate the view so it is valid to 
use. Using the debugger I've seen there are inflaters and views in 
SupportActionModeWrapper 
but it doesn't seem to expose anything like a ViewGroup I can use as a 
parent to inflate layout. I've tried various methods and they mostly result 
in one of those two behaviors:

   1. the action mode bar is empty (only ← is shown). This is the case if I 
   inflate with null root.
   2. I get a crash due to my view already having a parent. Trace suggests 
   to call .removeView on the root I used to inflate but apparently that needs 
   to be done recursively as doing that for the view I inflated didn't do a 
   thing.

How is setCustomView supposed to be used?

I was thinking about creating a menu with a <group> and try to put stuff 
there but it doesn't look like MenuItem supports this kind of use.
BTW, what is a proper root? For the lack of a better candidate, I used the 
activity content layout I've marked using an ID but I know this is not 
right. I would expect the ActionMode to contain some kind of layout - and 
I've seen something similar by walking in it using the debugger but I don't 
see any public interface to access the root.

I've read the "menus" API guide 
<http://developer.android.com/guide/topics/ui/menus.html#CAB> over and over 
and looked all across the documentation. Shouldn't there be a 
getSupportActionModeBar() kind of thing?

I've found several information on the net about .setCustomView but they 
seem to be related to (I assume to be) obsolete action bar versions. I 
don't recall finding anything useful.

I would eventually consider other UI designs but of course this would be my 
first choice.
Pretty much everything would be appreciated at this point, including simple 
search keywords!

Thanks in advance
Massimo

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/e8d0adca-bb0e-4cf6-9a72-b73d34a249f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to