set View Overflow Style Always - Android User Interface

Android examples for User Interface:View

Description

set View Overflow Style Always

Demo Code


//package com.java2s;
import java.lang.reflect.Field;

import android.content.Context;
import android.util.Log;

import android.view.ViewConfiguration;

public class Main {
    public static void setOverflowStyleAlways(Context context) {
        ViewConfiguration config = ViewConfiguration.get(context);
        try {//from w  ww . ja  va 2  s .c o m
            Field menuKey = config.getClass().getDeclaredField(
                    "sHasPermanentMenuKey");
            menuKey.setAccessible(true);
            menuKey.setBoolean(config, false);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

    }
}

Related Tutorials