@SuppressLint("AlwaysShowAction")
    public static void extendMenuActionBarDisplayItemCount(final Context ctx, final Menu menu) {

        final Configuration config = ctx.getResources().getConfiguration();
        final int width = config.screenWidthDp;

        int extendTo = 0;

        //RULES to extend AS ALWAYS are decoded here. See rules of Android in {@link androidx.appcompat.view.ActionBarPolicy#getMaxActionButtons}
        if (width >= 410) {
            extendTo = 4;
        } else if (width >= 360) {
            extendTo = 3;
        }

        for (int pos = 0; pos < menu.size() && pos < extendTo; pos++) {
            final MenuItem item = menu.getItem(pos);
            item.setShowAsAction(SHOW_AS_ACTION_ALWAYS);
        }

    }
Sets ListView height dynamically based on the height of the items.

@param listView to be resized
@return true if the listView is successfully resized, false otherwise
main/src/main/java/cgeo/geocaching/ui/ViewUtils.java