何时调用 inputmethodservice.gmd hide soft keyssoftinput

static&interface
InputMethod.SessionCallback
&&&&&&&&&&&
static&String
SERVICE_INTERFACE
&&&&&&&&&&This is the interface name that a service implementing an input
method should say that it supports -- that is, this is the action it
uses for its intent filter.
static&String
SERVICE_META_DATA
&&&&&&&&&&Name under which an InputMethod service component publishes information
about itself.
static&int
SHOW_EXPLICIT
&&&&&&&&&&Flag for showSoftInput(int, android.os.ResultReceiver): this show has been explicitly
requested by the user.
static&int
SHOW_FORCED
&&&&&&&&&&Flag for showSoftInput(int, android.os.ResultReceiver): this show has been forced to
happen by the user.
attachToken(IBinder&token)
&&&&&&&&&&Called first thing after an input method is created, this supplies a
unique token for the session it has with the system service.
bindInput(InputBinding&binding)
&&&&&&&&&&Bind a new application environment in to the input method, so that it
can later start and stop input processing.
createSession(InputMethod.SessionCallback&callback)
&&&&&&&&&&Create a new InputMethodSession that can be handed to client
applications for interacting with the input method.
hideSoftInput(int&flags,
ResultReceiver&resultReceiver)
&&&&&&&&&&Request that any soft input part of the input method be hidden from the user.
restartInput(InputConnection&inputConnection,
EditorInfo&attribute)
&&&&&&&&&&This method is called when the state of this input method needs to be
revokeSession(InputMethodSession&session)
&&&&&&&&&&Disable and destroy a session that was previously created with
createSession(android.view.inputmethod.InputMethod.SessionCallback).
setSessionEnabled(InputMethodSession&session,
boolean&enabled)
&&&&&&&&&&Control whether a particular input method session is active.
showSoftInput(int&flags,
ResultReceiver&resultReceiver)
&&&&&&&&&&Request that any soft input part of the input method be shown to the user.
startInput(InputConnection&inputConnection,
EditorInfo&info)
&&&&&&&&&&This method is called when the application starts to receive text and it
is ready for this input method to process received events and send result
text back to the application.
unbindInput()
&&&&&&&&&&Unbind an application environment, called when the information previously
set by bindInput(android.view.inputmethod.InputBinding) is no longer valid for this input method.
SERVICE_INTERFACE
static final String SERVICE_INTERFACE
This is the interface name that a service implementing an input
method should say that it supports -- that is, this is the action it
uses for its intent filter.
(Note: this name is used because this
interface should be moved to the view package.)
另请参见:常量字段值
SERVICE_META_DATA
static final String SERVICE_META_DATA
Name under which an InputMethod service component publishes information
about itself.
This meta-data must reference an XML resource containing
&input-method&
另请参见:常量字段值
SHOW_EXPLICIT
static final int SHOW_EXPLICIT
Flag for showSoftInput(int, android.os.ResultReceiver): this show has been explicitly
requested by the user.
If not set, the system has decided it may be
a good idea to show the input method based on a navigation operation
in the UI.
另请参见:常量字段值
SHOW_FORCED
static final int SHOW_FORCED
Flag for showSoftInput(int, android.os.ResultReceiver): this show has been forced to
happen by the user.
If set, the input method should remain visible
until deliberated dismissed by the user in its UI.
另请参见:常量字段值
attachToken
void attachToken(IBinder&token)
Called first thing after an input method is created, this supplies a
unique token for the session it has with the system service.
needed to identify itself with the service to validate its operations.
This token must not be passed to applications, since
it grants special priviledges that should not be given to applications.
Note: to protect yourself from malicious clients, you should only
accept the first token given to you.
Any after that may come from the
void bindInput(InputBinding&binding)
Bind a new application environment in to the input method, so that it
can later start and stop input processing.
Typically this method is called when this input method is enabled in an
application for the first time.
参数:binding - Information about the application window that is binding
to the input method.另请参见:InputBinding,
unbindInput()
unbindInput
void unbindInput()
Unbind an application environment, called when the information previously
set by bindInput(android.view.inputmethod.InputBinding) is no longer valid for this input method.
Typically this method is called when the application changes to be
non-foreground.
startInput
void startInput(InputConnection&inputConnection,
EditorInfo&info)
This method is called when the application starts to receive text and it
is ready for this input method to process received events and send result
text back to the application.
参数:inputConnection - Optional specific input connection for
communicati if null, you should use the generic
bound input connection.info - Information about the text box (typically, an EditText)
that requests input.另请参见:EditorInfo
restartInput
void restartInput(InputConnection&inputConnection,
EditorInfo&attribute)
This method is called when the state of this input method needs to be
Typically, this method is called when the input focus is moved from one
text box to another.
参数:inputConnection - Optional specific input connection for
communicati if null, you should use the generic
bound input connection.attribute - The attribute of the text box (typically, a EditText)
that requests input.另请参见:EditorInfo
createSession
void createSession(InputMethod.SessionCallback&callback)
Create a new InputMethodSession that can be handed to client
applications for interacting with the input method.
You can later
use revokeSession(InputMethodSession) to destroy the session
so that it can no longer be used by any clients.
参数:callback - Interface that is called with the newly created session.
setSessionEnabled
void setSessionEnabled(InputMethodSession&session,
boolean&enabled)
Control whether a particular input method session is active.
参数:session - The InputMethodSession previously provided through
SessionCallback.sessionCreated() that is to be changed.
revokeSession
void revokeSession(InputMethodSession&session)
Disable and destroy a session that was previously created with
createSession(android.view.inputmethod.InputMethod.SessionCallback).
After this call, the given session interface is no longer active and
calls on it will fail.
参数:session - The InputMethodSession previously provided through
SessionCallback.sessionCreated() that is to be revoked.
showSoftInput
void showSoftInput(int&flags,
ResultReceiver&resultReceiver)
Request that any soft input part of the input method be shown to the user.
参数:flags - Provides additional information about the show request.
Currently may be 0 or have the bit SHOW_EXPLICIT set.resultReceiver - The client requesting the show may wish to
be told the impact of their request, which should be supplied here.
The result code should be
InputMethodManager.RESULT_UNCHANGED_SHOWN,
InputMethodManager.RESULT_UNCHANGED_HIDDEN,
InputMethodManager.RESULT_SHOWN, or
InputMethodManager.RESULT_HIDDEN.
hideSoftInput
void hideSoftInput(int&flags,
ResultReceiver&resultReceiver)Request that any soft input part of the input method be hidden from the user.参数:flags - Provides additional information about the show request.Currently always 0.resultReceiver - The client requesting the show may wish tobe told the impact of their request, which should be supplied here.The result code should beInputMethodManager.RESULT_UNCHANGED_SHOWN,InputMethodManager.RESULT_UNCHANGED_HIDDEN,InputMethodManager.RESULT_SHOWN, orInputMethodManager.RESULT_HIDDEN.
JAVA下的InputMethod使用方法和示例
上一篇:下一篇:
InputMethod相关文章请点击
责任申明:本站内容均整理自互联网,若有侵权,请联系我们。使用本站提供的任务技术内容造成不良后果,本站不负任何责任。
欢迎投稿,电子邮件:(#号换成@)&& QQ群1: &&10961人阅读
android(65)
这几天在做自动弹出与隐藏软键盘,EditText在不同的使用环境下调用的方法是不一样的,找不到通用万能的方法,网上写的那些方法也只能作参考,不通用;这里总结一下我的心得,写出来分享给大家,希望对大家有帮助。
1.普通Activity中调用软键盘(下面两种方法都可以用):
WindowManager.LayoutParams params = act.getWindow().getAttributes();
& & & & & & // 隐藏软键盘
& & & & act.getWindow().setSoftInputMode(
& & & & & & & & & & WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
& & & & & & params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
& &&//显示软键盘
& & & & act.getWindow().setSoftInputMode(
& & & & & & & & & & WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
& & & & & & params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE;
//显示软键盘
mReasonEt.requestFocus();
InputMethodManager imm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE); &
& & imm.showSoftInput(mReasonEt, 0); &
//隐藏软键盘
mReasonEt.requestFocus();
InputMethodManager imm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE); &
& & imm.hideSoftInputFromInputMethod(mReasonEt.getWindowToken(), 0);
2.TabActivity中嵌套的子Activity中调用软键盘:
//显示软键盘
mReasonEt.requestFocus();
InputMethodManager imm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE); &
& & imm.showSoftInput(mReasonEt, 0); &
//隐藏软键盘
mReasonEt.requestFocus();
InputMethodManager imm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE); &
& && imm.hideSoftInputFromInputMethod(mReasonEt.getWindowToken(), 0);
在TabActivity中调用软键盘,默认会把底部Tab菜单推上去,导致界面显示和操作不方便,可以设置Activity的属性,让键盘直接覆盖底部tab菜单;如下:
androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode=&adjustPan&
3.自定义Dialog中的EditText调用软键盘:
//显示软键盘
myDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
//显示键盘(这个方法针对三星9100使用)
& & & & warningDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
//隐藏软键盘
myDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
&// 隐藏软键盘(这个方法针对三星9100使用)
&WindowManager.LayoutParams params = getWindow().getAttributes();
&getWindow().setSoftInputMode(
&WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
&params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
4.捕获屏幕点击事件,隐藏输入法
&getWindow().getDecorView().setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(v.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
& & & & });
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:374912次
积分:4409
积分:4409
排名:第4258名
原创:66篇
转载:57篇
评论:99条
(1)(4)(16)(5)(6)(2)(6)(2)(1)(4)(3)(1)(2)(2)(3)(8)(2)(1)(3)(2)(3)(7)(7)(5)(3)(1)(1)(2)(2)(2)(8)(6)(3)移动开发Web前端架构设计编程语言互联网数据库系统运维云计算研发管理
新博客专家介绍
Google提出了全新的设计规范Material Design,扁平化的设计,加上明亮的色彩,有一种美不胜收的感觉。Material Design翻译过来叫做“材料设计”,Material Design是多种元素组合在一起形成一个层次的效果,有主题、新的控件、动画,那么使用Material Design要注意些什么呢?下面来看看使用的注意点:1.保证兼容性,可以兼容市场占有率高的低版本系统
下面来初...
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处.
如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢!)
网上有一段Core Animation层动画的例子,是将view中的云朵从左向右移动,直到移出屏幕,这时再将云朵移到最左端然后重复移动动画.所有动画在layer上完成,不过有个小问题,就是第一次每朵云动画完成时,会在其原位置处有一个闪烁,然后才会移动到屏幕最...
故事缘于一位朋友的一道题:
朋友四人玩LOL游戏。第一局,分别选择位置:中单,上单,ADC,辅助;第二局新加入的伙伴要选上单,四人可选位置变为:中单,打野,ADC,辅助;要求,第二局四人每人不得选择和第一局相同的位置,请问两局综合考虑有多少种位置选择方式?
对于像我这边不懂游戏的人来讲,看不懂。于是有了这个版本:
有4个人,4只椅子,第一局每人坐一只椅子,第二...
针对app线上修复技术,目前有好几种解决方案,开源界往往一个方案会有好几种实现。重复的实现会有造轮子之嫌,但分析解决方案在技术上的探索和衍变,这轮子还是值得去推动的关于Hot Fix技术Hot Fix技术,简单来说就是针对线上已发布app出现了bug,在不推送新版本的情况下通过发布修复补丁进行修复。通常是刚上线的app,需要快速线上修复bug,类似的技术就叫做热修复或热补丁。热修复技术能带来什么让...
本节为大家介绍的软件叫安全洋葱Security Onion,根OSSIM一样,它是基于DebianLinux的系统,内部集成了很多开源安全工具,NIDS、HIDS、各种监控工具等等,下面我们就一起体会一下它如何进行深层防御。...
AngularJS 简介
AngularJS 是由 Google 发起的一款开源的前端 MVC 脚本框架,既适合做普通 WEB 应用也可以做 SPA(单页面应用,所有的用户操作都在一个页面中完成)。与同为 MVC 框架的 Dojo 的定位不同,AngularJS 在功能上更加轻量,而相比于 jQuery,AngularJS 又帮您省去了许多机械的绑定工作。在一些对开发速度要求高,功能模块不需...
emca -deconfig dbcontrol db
emca -repos drop
emca -config dbcontrol db -repos create...
注解方式:
@persistenceContext:持续、存留;环境、上下文;
@Stateless: 无状态(无权的)
@Remote:  远程接口
一、EJB接口
remote和local的?
二、(Enterprice JavaBeans )EJB基础知识:
①EJB是一个用于分布式业务应用的标准服务端组件模型。采用EJB架构编写的应用是可伸的、事务性的、多用户安...
玩过Linux的人都会知道,Linux中的命令的确是非常多,但是玩过Linux的人也从来不会因为Linux的命令如此之多而烦恼,因为我们只需要掌握我们最常用的命令就可以了。当然你也可以在使用时去找一下man,他会帮你解决不少的问题。然而每个人玩Linux的目的都不同,所以他们常用的命令也就差异非常大,而我主要是用Linux进行C/C++和shell程序编写的,所以常用到的命令可以就会跟一个管理Li...
Linux命令大全完整版
目    录I
1. linux系统管理命令1 
  
chfn(change finger information)1
chsh(change shell)1
gitps(gnu interactive tools process st...
JAVA和C++之间有一堵由内存分配和垃圾收集技术所围成的高墙,墙外的人想进来,墙里面的人想出来。...
阿里的开源项目很多,这也跟@淘宝正明的开源态度密不可分。有很多重量级的项目,例如LVS、Tengine,或者很有实践价值的中间件,今天小编为大家汇总了阿里开源的项目,快来看看吧!
服务框架 Dubbo
Dubbo 是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和 Spring框架无缝集成。
JDBC连接...
协议(二)这篇紧接着前面的协议(一)继续总结。1.委托(代理)模式委托是一种设计模式,它允许 类 或 结构体 将一些需要它们负责的功能 交由(委托) 给其他的类型的实例。委托模式的实现很简单: 定义协议来封装那些需要被委托的函数和方法, 使其 遵循者 拥有这些被委托的 函数和方
法 。委托模式可以用来响应特定的动作或接收外部数据源提供的数据,而无需要知道外部数据源的类型信息。下面的例子是两个基于骰...
利用UICollectionView 实现轮播图 :
具体代码如下, 简单粗暴, :
ViewController.m
CollectionPhotosView
Created by 帝炎魔 on 16/5/30.
Copyright © 2016年 帝炎魔. All rights reserved.
转载请标明出处:
http://blog.csdn.net/lmj/article/details/;
本文出自:【张鸿洋的博客】
从使用插件到编写插件,只差这一步。...
除了常用的画笔属性,比如普通的画笔(Paint),带边框、填充的style,颜色(Color),宽度(StrokeWidth),抗锯齿(ANTI_ALIAS_FLAG)等,Android还提供了各种各样专业的画笔工具,如记号笔、毛笔、蜡笔等,使用它们可以实现更加丰富的效果。...
利用UIScrollView实现轮播图 , 需要三个ImageView轮流切换,具体原理就不讲解了.
具体实现代码如下:
ViewController.m
PhotosShowDemo
Created by 帝炎魔 on 16/5/29.
Copyright © 2016年 帝炎魔. All rights reserv...
图书管理系统1.0
不定时更新。
请不要拿去当作业。。。...
一、SpringMVC基础入门,创建一个HelloWorld程序
  1.首先,导入SpringMVC需要的jar包。
  2.添加Web.xml配置文件中关于SpringMVC的配置
    servlet-name&spri...
接着上篇文章,现在在通过Android实际开发和源码再探观察者模式,listview是我们日常开发中必用的控件,虽然之前就有listview的替代品(recyclerview),现在不去深究两个控件到底谁好谁差,但有一点需要强调下,它们之间有一大相同点,都是通过观察者模式去实现数据更新。首先,我们先去看一个简单的例子/**
* created by zero on
Node是节点的抽象,里面包含节点引擎、客户端引擎、分区服务、集群服务、组播服务、连接管理、命令管理、组播属性、节点配置、本地成员、tcp地址、组播地址、连接者、节点初始化器、管理中心、安全上下文、Config类,包含GroupConfig、NetworkConfig、MapConfig、TopicConfig、QueueConfig、MultiMapConfig、ListConfig、SetCo...
142857是一个六位数,我们发现:
  =142857
  =285714
  =428571
  =571428
  =714285
  =857142
  即用1到6的整数去乘142857,会得到一个将原来的数首尾相接循环移动若干数字再在某处断开而得到的数字。
  也就是说,如果把原来的数字和新的数字都首尾相接,他们...
越来越多的服务走向云端,看不见摸不着,让没接触过的我感觉有些茫然,IBM的云平台Blumemix上提供了很多服务,我这里就把学习使用ClearDBMySQL Database服务的过程给大家分享一下。这是一个PHP的投票小程序,针对主题“你曾后悔进入 IT 行业吗?”展开投票功能,基于简单的Cookie操作判断用户有没有投过票,如果没有投过票,就显示投票选项和按钮,不显示投票结果;如果已经投票了,...
这本书我一定要推荐给程序员读,它可以让你具有判断力,能让你更好的看清自己所做的产品是否有前景,所在的公司是否有前景。...
贺老师,你好:
  我是河南XX大学计算机专业的一名大二学生,关注您的博客很久了,收获颇丰,谢谢您的付出。最近我们专业要分方向了,有硬件和软件两个选择;我对硬件非常的感兴趣况且编程对我而言有点力不从心,但是我们学校对硬件并不是特别的重视,我该如何选择?希望老师能给出一些合理化的建议和分析硬件和软件各自的发展方向及前景。谢谢!【回复】
  从我的角度,我一直赞成大学生要以自己...
SortedWordCount源代码以及过程分析运行截图:
代码逻辑:Sort.java//Sort.java--目的key从大到小排序import java.io.DataI
import java.io.DataO
import java.io.IOEimport org.apache.hadoop.conf.Confi...
第十二章 并发编程如果逻辑控制流在时间上是重叠,那么它们就是并发的(concurrent)。这种常见的现象称为并发(concurrency)。
硬件异常处理程序,进程和Unix信号处理程序都是大家熟悉的例子。
我们主要将并发看做是一种操作系统内核用来运行多个应用程序的机制。
但是,并发不仅仅局限于内核。它也可以在应用程序中扮演重要的角色。例如Unix信号处理程序如何允许应用响应异步事件
例如:用户...
原文来自:点击打开链接
jQuery Validate
jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求。该插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证,同时提供了一个用来编写用户自定义方法的 API。所有的捆绑方法默认使用英语作为错误信息,且已翻译成其他 37 种语...
开始我们的Activity不同于使用 main() 方法启动应用的其他编程范例,Android 系统会通过调用对应于其生命周期中特定阶段的特定回调方法在 Activity 实例中启动代码。 有一系列可启动Activity的回调方法,以及一系列可分解Activity的回调方法。
每个activity的入口时ActivityThread的main函数
本文概述了最重要的生命周期方法,并向大家展示如何...
状态模式(State Pattern)
概念:状态模式 允许对象在内部状态改变时改变它的行为,对象看起来好像修改了它的类
在软件设计中,我们经常会遇需要编写有很多状态的程序。最简单的如乘坐电梯程序,当我们要坐电梯时需要判断电梯的状态,只有当电梯处于当前楼时我们才能乘坐,当电梯不在当前楼层时我们要按下按钮等待电梯到来。在平时一般都通过 if…else 或者 switch 判断状态后处理,这种固定...
博客频道公告
相关知识库
两天热门文章
博客最新评论
:很不错的分享,学习啦!
:@xiaopao319:哈哈哈,我也在努力学习,多交流
:很不错的分享,学习啦!
:@qq_:这个已经修改了,在activity被销毁的时候,会调用 persenter...
:很不错的分享,学习啦!
:很不错的分享,学习啦!
:很不错的分享,学习啦!
:很不错的分享,学习啦!
:博主威武,持续学习中
:很不错的分享,学习啦!
:很不错的分享,学习啦!
:很不错的分享,学习啦!
:很不错的分享,学习啦!
:很不错的分享,学习啦!
:很不错的分享,学习啦!下次自动登录
现在的位置:
& 综合 & 正文
Robotium 之Android 功能自动化测试关于关键盘弹出的处理
在利用Robotium做功能自动化测试的时候,常常由于一些EditText等的虚拟键盘弹出问题,导致额外的工作量来处理虚拟键盘的问题。
现在指定一种处理虚拟键盘的方法:
InputMethodManager:
Central system API to the overall input method framework (IMF) architecture, which arbitrates interaction between applications and the current input method. You can retrieve an instance of this interface with .
InputMethodManager是用来控制输入法的:
Java InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
Java代码 if (imm.isActive())
来检查虚拟键盘是不是在开启的状态
然后可以用toggle方法来关闭它
Java代码 imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
当然如果当前虚拟键盘是关闭的, toggle就会开启键盘.
InputMethodManager也有独立开启和关闭的方法:
Java代码 imm.showSoftInput(view, flags);
imm.showSoftInputFromInputMethod(token, flags);
imm.hideSoftInputFromInputMethod(token, flags);
在robotium种如此处理:
InputMethodManager imm = (InputMethodManager) solo.getCurrentActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
assertTrue(imm.isActive());
转载地址:/maguowei/item/97f61e21e250aa
&&&&推荐文章:
【上篇】【下篇】

我要回帖

更多关于 input hide 的文章

 

随机推荐