GridPasswordView icon indicating copy to clipboard operation
GridPasswordView copied to clipboard

能否添加一个获取焦点的方法

Open star-andy opened this issue 9 years ago • 5 comments

现在view不点击不会自动获取焦点

star-andy avatar May 10 '16 02:05 star-andy

gridPasswordView.postDelayed(new Runnable() { @Override public void run() { gridPasswordView.forceInputViewGetFocus(); } },100);

需要把 forceInputViewGetFocus 改为public的

CSnowStack avatar Feb 14 '17 03:02 CSnowStack

无法改动源码,有什么好的解决方案ma?^_^

w3812127 avatar Apr 08 '17 03:04 w3812127

@w3812127 ctrl c ctrl v.

HotBitmapGG avatar Apr 08 '17 03:04 HotBitmapGG

passwordView.postDelayed(new Runnable() { @Override public void run() { try { setObjectFunction(passwordView); }catch (Exception e){ e.printStackTrace(); } } },100); }

public static void setObjectFunction(Object obj) throws SecurityException, NoSuchMethodException,
        IllegalArgumentException, InvocationTargetException, IllegalAccessException {
        Class cls = obj.getClass();
        // 获得类的私有方法
        Method method = cls.getDeclaredMethod("forceInputViewGetFocus", null);
        method.setAccessible(true); // 没有设置就会报错,设置可以调用私有方法。
        // 调用该方法
        method.invoke(obj, null);
}

w3812127 avatar Apr 08 '17 03:04 w3812127

passwordView.postDelayed(new Runnable() { @override public void run() { try { setObjectFunction(passwordView); }catch (Exception e){ e.printStackTrace(); } } },100); }

public static void setObjectFunction(Object obj) throws SecurityException, NoSuchMethodException,
        IllegalArgumentException, InvocationTargetException, IllegalAccessException {
        Class cls = obj.getClass();
        // 获得类的私有方法
        Method method = cls.getDeclaredMethod("forceInputViewGetFocus", null);
        method.setAccessible(true); // 没有设置就会报错,设置可以调用私有方法。
        // 调用该方法
        method.invoke(obj, null);
}

使用反射是正解😆

1130381752 avatar Nov 16 '18 06:11 1130381752