5,593,248 Members 32,830 Now Online
XDA Developers Android and Mobile Development Forum

Show spinner on left when ActionMode is active

Tip us?
 
dafiduck
Old
#1  
dafiduck's Avatar
Junior Member - OP
Thanks Meter 3
Posts: 21
Join Date: Oct 2013
Default Show spinner on left when ActionMode is active

I have a gridview supporting multiple selection, when user selects one item the action bar shows the classic AcitonMode and the menu items as defined in layout/menu files, every works fine.

Now I want to add a spinner and show it on the left side (like Gallery does) but defining it on the menu.xml it is positioned near other menu items (on right), so how can I create a spinner on left side and menu items on right side like on Gallery app??

I've searched on Gallery source code but it is really complicated

My current menu definition is show below

Code:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/action_selection_spinner"
        android:actionViewClass="android.widget.Spinner"
        android:showAsAction="always"/>
    <item
        android:id="@+id/action_edit"
        android:showAsAction="always"
        android:title="@string/edit_title"/>

</menu>

My onPrepareActionMode method
Code:
    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {

        Spinner selectionSpinner = (Spinner) menu.findItem(
                R.id.item_selection_spinner).getActionView();
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActionBar()
                .getThemedContext(), R.layout.path_spinner_dropdown_item);

        selectionSpinner.setAdapter(adapter);
        adapter.addAll("One item selected", "Select All");

        return true;
    }
Nexus 7 Not rooted 4.4.2, it's too young yet
Samsung Galaxy Tab 10.1 (P7500) Ganbarou 4.3.1
iPad 2 Ok nobody is perfect, please apologize me
 
EmptinessFiller
Old
#2  
Member
Thanks Meter 21
Posts: 88
Join Date: Sep 2013
I'm not sure, but I think you have to use a custom layout instead of your menu-xml file.
Regards
The Following User Says Thank You to EmptinessFiller For This Useful Post: [ Click to Expand ]
 
dafiduck
Old
#3  
dafiduck's Avatar
Junior Member - OP
Thanks Meter 3
Posts: 21
Join Date: Oct 2013
Quote:
Originally Posted by EmptinessFiller View Post
I'm not sure, but I think you have to use a custom layout instead of your menu-xml file.
Regards
Yes, using setCustomView works fine, thanks
Nexus 7 Not rooted 4.4.2, it's too young yet
Samsung Galaxy Tab 10.1 (P7500) Ganbarou 4.3.1
iPad 2 Ok nobody is perfect, please apologize me
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes