Hi I am developing an android application. In my application I am using ActionBarSherlock. I defined few menu items in the action-bar, in the following way:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/card_menu"
android:title="cards"
android:showAsAction="always"
android:actionLayout="@layout/action_button"
>
<menu>
<item android:id="@+id/C1"
android:title="C1" />
<item android:id="@+id/C2"
android:title="c2" />
<item android:id="@+id/C3"
android:title="C3" />
</menu>
</item>
<item android:id="@+id/notification"
android:title="Notifications"
android:showAsAction="always"
android:actionLayout="@layout/notification_icon"
android:icon="@drawable/notification"
/>
<item android:id="@+id/filter"
android:icon="@drawable/filter"
android:title="Filter"
android:showAsAction="always"
/>
Now, everything displayed very well, but my problem is that when I click on a card_menu item where I define sub menus and also define an action layout; it's not showing those sub menus.
My other menu items are working properly. Only when I define an action layout for my item which contains sub menus at that time I am not able to display the sub menu.
If I remove the action layout, then it's working fine...
I know if we define an action layout for an item, then we have to manually handle the click listener. I did that the following way:
final MenuItem item = menu.findItem(R.id.card_menu);
item.getActionView().setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onOptionsItemSelected(item);
Toast.makeText(getActivity(), "click on menu", Toast.LENGTH_SHORT).show();
}
});
I am able to handle the click event for that item, but not able to show drop-down sub menu items..
How to solve this problem? How can I open my sub menus?
Need Help.... Thank you...