从品牌网站建设到网络营销策划,从策略到执行的一站式服务
目前很多的输入法都有自动提示补全功能,在一些应用场景里不适用,需要禁用系统输入法,自定义软键盘,EditText的光标问题是比较头疼的,网上的说法很多,然而大部分都是解决不了问题的。以下是本人做的一个demo供网友参考。
长宁网站建设公司成都创新互联公司,长宁网站设计制作,有大型网站制作公司丰富经验。已为长宁上千家提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的长宁做网站的公司定做!
直接上代码:
xml软键盘:
禁用系统输入法,解决EditText光标问题的重要代码:
public boolean onTouch(View v, MotionEvent event) { //隐藏输入法,显示光标 EditText et=(EditText)v; int inType = et.getInputType(); // back up the input type if (sdkInt>=11) { Classcls=EditText.class; try { Method setShowSoftInputOnFocus=cls.getMethod("setShowSoftInputOnFocus", boolean.class); setShowSoftInputOnFocus.setAccessible(false); setShowSoftInputOnFocus.invoke(et, false); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }else { et.setInputType(android.text.InputType.TYPE_NULL); // disable soft input et.setInputType(inType); } keyboardUtil=null; keyboardUtil = new KeyboardUtil(act, ctx, et); et.onTouchEvent(event);// call native handler // restore input type keyboardUtil.showKeyboard(); return true; }
其他代码就不贴了,需要完整demo的请自行下载。
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图