public static int getMinimalWidth(final Context ctx, final String text, final int styleId) {
        final TextView tv = new TextView(ctx, null, 0, styleId);
        tv.setText(text);
        tv.measure(0, 0);
        return tv.getMeasuredWidth();

    }
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