Skip to content Skip to sidebar Skip to footer

Not Able To Get The Overflow Feature For Actionbar In Android

What i am trying to do :: What is happening :: My code:: actionbar_sort_menu.xml Copy

Then change this

  android:showAsAction="ifRoom|withText"

to

  yourapp:showAsAction="ifRoom|withText"

Note : If there is not enough space to display items in the actionbar it will appear in the overflow menu. If you have room for few items it appears on the actionbar and the rest in overflow.

Edit:

yourapp:showAsAction="never"

From the docs

http://developer.android.com/guide/topics/resources/menu-resource.html

 never  Never place this item in the Action Bar.   

Solution 2:

  • Well This was just a workaround to get the answer as below
  • Since i am not having the device to test for the solution to test Raghunandan answer
  • I still believe Raghunandan answer holds good & also sharing what i came to do

Reason for me to test on mobile because:: "device has a menu-button, the overflow-icon won't show."


Code::

@OverridepublicbooleanonOptionsItemSelected(MenuItem item) {   
    ft = getFragmentManager().beginTransaction();

    switch(item.getItemId()) {
    case R.id.descriptionID:
        onItemChangeBackground(1);

        FragmentfragContents= FrgBufDetails.newInstance(buf_off_id);
        ft.replace(R.id.content_frame, fragContents);
        ft.addToBackStack(null);
        ft.commit();

        returntrue;
    case R.id.MapID:
        onItemChangeBackground(2);

        FragmentfragMap= FrgBufLocation.newInstance(buf_off_id);
        ft.replace(R.id.content_frame, fragMap);
        ft.addToBackStack(null);
        ft.commit();

        returntrue;
    case R.id.galleryID:
        onItemChangeBackground(3);

        FragmentfragGallery= FrgBufGallery.newInstance(buf_off_id);
        ft.replace(R.id.content_frame, fragGallery);
        ft.addToBackStack(null);
        ft.commit();

        returntrue;
    case R.id.inviteID:
        onItemChangeBackground(4);

        Viewtitle= (View) getActivity()
                    .findViewById(R.id.inviteID);

        //Creating the instance of PopupMenuPopupMenupopup=newPopupMenu(getActivity(), title);
        //Inflating the Popup using xml file
        popup.getMenuInflater().inflate(R.menu.actionbar_sort_menu, popup.getMenu());
        popup.show();//showing popup menureturntrue;
    }
    returnsuper.onOptionsItemSelected(item);
}

Post a Comment for "Not Able To Get The Overflow Feature For Actionbar In Android"