当前位置:首页 » 安卓系统 » android不弹出输入法

android不弹出输入法

发布时间: 2022-06-07 15:48:28

1. Android的EditText长按只显示上面的复制粘贴菜单,不要弹出下面的输入法键盘怎么做

4.0以上的API禁止EditText弹出键盘需要这样写:

4.0的是setShowSoftInputOnFocus,4.2的是setSoftInputOnFocus。

java">EditTexteditText;
//editText的实例化我不写了
InputMethodManagerimm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(e1.getWindowToken(),0);
try{
Class<EditText>cls=EditText.class;
setSoftInputShownOnFocus=cls.getMethod("setShowSoftInputOnFocus",boolean.class);
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(editText,false);
}catch(Exceptione){
e.printStackTrace();
}

并且还要在配置文件里面加上android:windowSoftInputMode="stateHidden"

4.0以下的可用editText.setInputType(InputType.TYPE_NULL);

或者直接在XML进行属性设置。

如果对4.0以上系统的操作这句代码,EditText将会没有光标。

2. Android中EditTex焦点设置和弹不弹出输入法的问题

在网上看了些例子都不够全面,在这里全面总结下。
一:EditText为什么会默认弹出输入法?

同样的代码,碰到有EditText控件的界面时有的机子会弹出输入法,有的机子不会弹出。不好意思,这问题我也一头雾水,谁知道可以告诉我,否则我就把这个问题留下来,以后研究android源码时再搞个清楚。但是...我有解决方案。

二:默认弹出和默认关闭输入法的解决方案。

1.默认关闭,不至于进入Activity就打开输入法,影响界面美观。

①在布局文件中,在EditText前面放置一个看不到的LinearLayout,让他率先获取焦点:
<LinearLayout

android:focusable="true"

android:focusableInTouchMode="true"

android:layout_width="0px"

android:layout_height="0px"/>
②方法二:先看一个属性android:inputType:指定输入法的类型,int类型,可以用|选择多个。取值可以参考:android.text.InputType类。取值包括:text,textUri,
phone,number,等.

Android SDK中有这么一句话“If
the given content type is TYPE_NULL
then a soft keyboard will not be displayed for this text view”,

先将EditText的InputType改变为TYPE_NULL,输入法就不会弹出.然后再设置监听,再重新设置它的InputType.
editText.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int inType = editText.getInputType(); // backup the input type
editText.setInputType(InputType.TYPE_NULL); // disable soft input
editText.onTouchEvent(event); // call native handler
editText.setInputType(inType); // restore input type
return true;
}
});
2.默认弹出。有时候按照需求可能要求默认弹出输入法。方案如下:
EditText titleInput = (EditText) findViewById(R.id.create_edit_title);titleInput.setFocusable(true);

titleInput.requestFocus();
onFocusChange(titleInput.isFocused());

private void onFocusChange(boolean hasFocus)
{
final boolean isFocus = hasFocus;
(new Handler()).postDelayed(new Runnable() {
public void run() {
InputMethodManager imm = (InputMethodManager)
titleInput.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if(isFocus)
{
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
else
{
imm.hideSoftInputFromWindow(titleInput.getWindowToken(),0);
}
}
}, 100);
}
转载

3. htc的android手机不能输入文字了,打开任何文字输入框都没反应,弹不出输入法!怎么办啊!急急急急急!

输入法被关闭了,具体流程:设置-查看输入法是否在设备内存(点一下输入法-下面有个移至内部储存卡-点一下)-把输入法设成默认(在菜单栏里点一下输入法,根据提示操作)-搞定
还不行追问我

4. 输入法弹不出来了怎么办.自带的安卓输入法也不行

一、设置方法:

1
下面,我们以“网络输入法”为例来给大家讲解怎么设置。首先,调出手机的菜单,选择“设置”。

2
在设置中选择“语言和键盘”。

3
勾选“网络输入法”。

4
如果此时弹出注意事项,点击“确定”。
在这里顺便说一句,如果你对各大厂商的中文输入法均存有戒心,输密码啥的你就不要用中文输入法切换到英文模式输了,用手机系统自带的原生英文键盘吧。

5
点击“网络输入法”的设置项。

6
在打开的界面中,因为第一步我们已经完成了,所以就点击第二步中的“去切换”。

7
将“网络输入法”设为默认。

8
现在退回到原来的界面后,“完成”按钮就已经可用了,点击“完成”。这样,输入法就设置好了。

END
二、测试验证:

现在,我们来发一条短信测试下。
点击进入短信编辑界面,网络输入法立刻就自动调出来了。

5. 手机输入法老是弹不出来

你先打开设置菜单。在设置里面找到对应的功能选项!

6. android EditText 不能自动弹出“输入法” ,isInputMethodTarget为false,能否设置成true。

可以有两种方式:
1、在AndroidManifest.xml中指定输入法弹出策略
2、在进入Activity之后,用Handler延迟数百毫秒弹出输入法

7. Android4.0 EidtText不弹出输入法

看一个manifest中Activity的配置,如果这个页面有EditText,并且我们想要进入这个页面的时候默认弹出输入法,可以这样设置 这个属相:android:windowSoftInputMode=stateVisible,这样就会默认弹起输入法,当然还有别的办法。


<activityandroid:name=".ui.login"
android:configChanges="orientation|keyboardHidden|locale"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan">
</activity>

Android EditText 不弹出输入法总结

方法一:

在AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为 adjustUnspecified|stateHidden

例如:

<activityandroid:name=".Main"
android:label="@string/app_name"
android:windowSoftInputMode="adjustUnspecified|stateHidden"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<actionandroid:name="android.intent.action.MAIN"/>
<categoryandroid:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

方法二:

让EditText失去焦点,使用EditText的clearFocus方法

例如:

EditTextedit=(EditText)findViewById(R.id.edit);
edit.clearFocus();

方法三:

强制隐藏Android输入法窗口

例如:

EditTextedit=(EditText)findViewById(R.id.edit);
InputMethodManagerimm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);

2.EditText始终不弹出软件键盘

例:

EditTextedit=(EditText)findViewById(R.id.edit);
edit.setInputType(InputType.TYPE_NULL);

研究了下android中焦点Focus和弹出输入法的问题。在网上看了些例子都不够全面,在这里全面总结下。

一:EditText为什么会默认弹出输入法?

同样的代码,碰到有EditText控件的界面时有的机子会弹出输入法,有的机子不会弹出。不好意思,这问题我也一头雾水,谁知道可以告诉我,否则 我就把这个问题留下来,以后研究android 源码时再搞个清楚。但是...我有解决方案。

二:默认弹出和默认关闭输入法的解决方案。

1.默认关闭,不至于进入Activity就打开输入法,影响界面美观。

①在布局文件中,在EditText前面放置一个看不到的LinearLayout,让他率先获取焦点:

<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>

②方法二:先看一个属性android:inputType:指定输入法的类型,int类型,可以用|选择多个。取值可以参 考:android.text.InputType类。取值包括:text,textUri,

phone,number,等.

Android SDK中有这么一句话“If the given content type is TYPE_NULL then a soft keyboard will not be displayed for this text view”,

先将EditText的InputType改变为TYPE_NULL,输入法就不会弹出.然后再设置监听,再重新设置它的InputType.


editText.setOnTouchListener(newOnTouchListener(){
publicbooleanonTouch(Viewv,MotionEventevent){
//TODOAuto-generatedmethodstub
intinType=editText.getInputType();//backuptheinputtype
editText.setInputType(InputType.TYPE_NULL);//disablesoftinput
editText.onTouchEvent(event);//callnativehandler
editText.setInputType(inType);//restoreinputtype
returntrue;
}
});

2.默认弹出。有时候按照需求可能要求默认弹出输入法。方案如下:


EditTexttitleInput=(EditText)findViewById(R.id.create_edit_title);
titleInput.setFocusable(true);
titleInput.requestFocus();
onFocusChange(titleInput.isFocused());
privatevoidonFocusChange(booleanhasFocus)
{
finalbooleanisFocus=hasFocus;
(newHandler()).postDelayed(newRunnable(){
publicvoidrun(){
InputMethodManagerimm=(InputMethodManager)
titleInput.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if(isFocus)
{
imm.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
}
else
{
imm.hideSoftInputFromWindow(titleInput.getWindowToken(),0);
}
}
},100);
}

我觉得因为在Android的主线程中对UI的操作无效,所以必须在Handler中实现弹出输入法的操作。

三:关于焦点和输入法的个人理解

获取焦点是获取焦点,弹输入法是弹输入法。获取焦点后并不一定会弹出输入法,在网上搜了一圈,主流回答是“还有就是已开启界面就是focus的 text的话有可能也是不行的,UI渲染是需要时间的”......

由于对源码不懂,我对这一点也没有个全面的认识。只能将焦点和输入法分成两块来处理。焦点的打开和关闭特别简单。

焦点的获取:

titleInput.setFocusable(true);
titleInput.requestFocus();

焦点的取消:

titleInput.setFocusable(false);

四:关于经常调用的处理软键盘的函数如下:

1、打开输入法窗口:

=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

//接受软键盘输入的编辑文本或其它视图

imm.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);

2、关闭出入法窗口


=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(OpeListActivity.this.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);

//接受软键盘输入的编辑文本或其它视图

inputMethodManagerwww.2cto.com
.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);

3、如果输入法打开则关闭,如果没打开则打开

InputMethodManagerm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
m.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);

4、获取输入法打开的状态

InputMethodManagerimm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
booleanisOpen=imm.isActive();

isOpen若返回true,则表示输入法打开

8. android:自定义可输入对话框,EditText已经获得焦点,为什么就是不弹出输入法呢

因为你弹出的对话框跟MainActivity(假设你是在MainActivity上他弹出的)不在同一个Activity上,所以就显示不出来了,就算你能看到软键盘你也无法输入。

9. android怎样控制输入法的弹出和隐藏

1.让EditText失去焦点,使用EditText的clearFocus方法
2. 强制隐藏Android输入法窗口,在IME类中我们通过
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 实例化输入法控制对象,通过hideSoftInputFromWindow来控制,其中第一个参数绑定的为需要隐藏输入法的EditText对象,比如imm.hideSoftInputFromWindow(etAndroid123.getWindowToken(), 0);

10. android中edittex焦点设置和弹不弹出输入法的问题

一:EditText为什么会默认弹出输入法?

同样的代码,碰到有EditText控件的界面时有的机子会弹出输入法,有的机子不会弹出。不好意思,这问题我也一头雾水,谁知道可以告诉我,否则我就把这个问题留下来,以后研究android源码时再搞个清楚。但是...我有解决方案。

二:默认弹出和默认关闭输入法的解决方案。

1.默认关闭,不至于进入Activity就打开输入法,影响界面美观。

①在布局文件中,在EditText前面放置一个看不到的LinearLayout,让他率先获取焦点:

[html] view plainprint?
01.<LinearLayout
02.
03.android:focusable="true"
04.
05.android:focusableInTouchMode="true"
06.
07.android:layout_width="0px"
08.
09.android:layout_height="0px"/>
<LinearLayout

android:focusable="true"

android:focusableInTouchMode="true"

android:layout_width="0px"

android:layout_height="0px"/>

②方法二:先看一个属性android:inputType:指定输入法的类型,int类型,可以用|选择多个。取值可以参考:android.text.InputType类。取值包括:text,textUri,
phone,number,等.

Android SDK中有这么一句话“If
the given content type is TYPE_NULL then a soft keyboard will not be displayed for this text view”,

先将EditText的InputType改变为TYPE_NULL,输入法就不会弹出.然后再设置监听,再重新设置它的InputType.

[java] view plainprint?
01.editText.setOnTouchListener(new OnTouchListener() {
02. public boolean onTouch(View v, MotionEvent event) {
03. // TODO Auto-generated method stub
04. int inType = editText.getInputType(); // backup the input type
05. editText.setInputType(InputType.TYPE_NULL); // disable soft input
06. editText.onTouchEvent(event); // call native handler
07. editText.setInputType(inType); // restore input type
08. return true;
09. }
10. });
editText.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int inType = editText.getInputType(); // backup the input type
editText.setInputType(InputType.TYPE_NULL); // disable soft input
editText.onTouchEvent(event); // call native handler
editText.setInputType(inType); // restore input type
return true;
}
});

2.默认弹出。有时候按照需求可能要求默认弹出输入法。方案如下:

[java] view plainprint?
01.EditText titleInput = (EditText) findViewById(R.id.create_edit_title);titleInput.setFocusable(true);
02.
03.titleInput.requestFocus();
04. onFocusChange(titleInput.isFocused());
05.
06.private void onFocusChange(boolean hasFocus)
07.{
08.final boolean isFocus = hasFocus;
09.(new Handler()).postDelayed(new Runnable() {
10.public void run() {
11.InputMethodManager imm = (InputMethodManager)
12.titleInput.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
13.if(isFocus)
14.{
15.imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
16.}
17.else
18.{
19.imm.hideSoftInputFromWindow(titleInput.getWindowToken(),0);
20.}
21.}
22.}, 100);
23.}
EditText titleInput = (EditText) findViewById(R.id.create_edit_title);titleInput.setFocusable(true);

titleInput.requestFocus();
onFocusChange(titleInput.isFocused());

private void onFocusChange(boolean hasFocus)
{
final boolean isFocus = hasFocus;
(new Handler()).postDelayed(new Runnable() {
public void run() {
InputMethodManager imm = (InputMethodManager)
titleInput.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if(isFocus)
{
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
else
{
imm.hideSoftInputFromWindow(titleInput.getWindowToken(),0);
}
}
}, 100);
}

我觉得因为在Android的主线程中对UI的操作无效,所以必须在Handler中实现弹出输入法的操作

三。关于焦点和输入法的个人理解

获取焦点是获取焦点,弹输入法是弹输入法。获取焦点后并不一定会弹出输入法,在网上搜了一圈,主流回答是“还有就是已开启界面就是focus的text的话有可能也是不行的,UI渲染是需要时间的”......
由于对源码不懂,我对这一点也没有个全面的认识。只能将焦点和输入法分成两块来处理。焦点的打开和关闭特别简单。
焦点的获取:
titleInput.setFocusable(true);
titleInput.requestFocus();
焦点的取消:

titleInput.setFocusable(false);四。关于经常调用的处理软键盘的函数如下:<转载>
1、打开输入法窗口:

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

// 接受软键盘输入的编辑文本或其它视图

imm.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);

2、关闭出入法窗口

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

inputMethodManager.hideSoftInputFromWindow(OpeListActivity.this.getCurrentFocus().getWindowToken(),

InputMethodManager.HIDE_NOT_ALWAYS);

//接受软键盘输入的编辑文本或其它视图
inputMethodManager

.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);
3、如果输入法打开则关闭,如果没打开则打开

InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

4、获取输入法打开的状态

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
boolean isOpen=imm.isActive();
isOpen若返回true,则表示输入法打开
转载

热点内容
javafor循环嵌套if 发布:2025-08-18 23:28:21 浏览:299
西装配领算法 发布:2025-08-18 23:26:38 浏览:501
ecshopsql漏洞 发布:2025-08-18 23:17:01 浏览:799
mac临时文件夹 发布:2025-08-18 23:14:55 浏览:766
阿里云搭建传奇服务器 发布:2025-08-18 23:14:06 浏览:454
硬件加密卡 发布:2025-08-18 23:08:17 浏览:988
农信交易密码指的是什么密码 发布:2025-08-18 23:03:20 浏览:586
数组存储空间 发布:2025-08-18 23:01:50 浏览:748
如解压游戏 发布:2025-08-18 22:57:02 浏览:577
如何复制页游密码 发布:2025-08-18 22:49:13 浏览:387