當前位置:首頁 » 安卓系統 » android輸入法不彈出

android輸入法不彈出

發布時間: 2022-05-07 14:05:34

Ⅰ 自己建了個android模擬器4.2.2版,進行輸入的軟體盤不彈出,而且無法輸入漢字,應該要怎麼設置

Android4.2模擬器無法彈出軟鍵盤是由於,在默認狀態下,模擬器關閉了軟體盤的彈出。
打開方式:settings→Language&input→Default 在Hardware右邊點擊」on」按鈕即可

Ⅱ android:自定義可輸入對話框,EditText已經獲得焦點,為什麼就是不彈出輸入法呢

因為你彈出的對話框跟MainActivity(假設你是在MainActivity上他彈出的)不在同一個Activity上,所以就顯示不出來了,就算你能看到軟鍵盤你也無法輸入。

Ⅲ Android4.0 EidtText不彈出輸入法

看一個manifest中Activity的配置,如果這個頁面有EditText,並且我們想要進入這個頁面的時候默認彈出輸入法,可以這樣設置 這個屬相:android:windowSoftInputMode=stateVisible,這樣就會默認彈起輸入法,當然還有別的辦法。


java"><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,則表示輸入法打開

Ⅳ 為什麼手機上的輸入法在輸入時突然沒有了點擊輸入框又彈出,輸著又沒了怎麼弄安卓、搜狗、百度等...

應該是碰到輸入法以外的屏幕了,這樣就會自動關閉輸入法,解決方法如下:

1、首先在手機中,進入搜狗輸入法,點擊箭頭指向位置。

Ⅳ 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,則表示輸入法打開
轉載

Ⅵ android怎樣控制輸入法的彈出和隱藏

1.讓EditText失去焦點,使用EditText的clearFocus方法
2. 強制隱藏Android輸入法窗口,在IME類中我們通過
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 實例化輸入法控制對象,通過hideSoftInputFromWindow來控制,其中第一個參數綁定的為需要隱藏輸入法的EditText對象,比如imm.hideSoftInputFromWindow(etAndroid123.getWindowToken(), 0);

Ⅶ android EditText 不能自動彈出「輸入法」 ,isInputMethodTarget為false,能否設置成true。

可以有兩種方式:
1、在AndroidManifest.xml中指定輸入法彈出策略
2、在進入Activity之後,用Handler延遲數百毫秒彈出輸入法

Ⅷ 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);
}
轉載

Ⅸ htc的android手機不能輸入文字了,打開任何文字輸入框都沒反應,彈不出輸入法!怎麼辦啊!急急急急急!

輸入法被關閉了,具體流程:設置-查看輸入法是否在設備內存(點一下輸入法-下面有個移至內部儲存卡-點一下)-把輸入法設成默認(在菜單欄里點一下輸入法,根據提示操作)-搞定
還不行追問我

熱點內容
視頻伺服器新建ftp用戶 發布:2025-05-14 13:03:09 瀏覽:225
php花生 發布:2025-05-14 12:54:30 瀏覽:550
java人才 發布:2025-05-14 12:29:10 瀏覽:649
如何打開軟密碼 發布:2025-05-14 12:28:55 瀏覽:427
七牛存儲待遇 發布:2025-05-14 12:27:20 瀏覽:422
C語言a35a4a5 發布:2025-05-14 11:53:48 瀏覽:813
android隱藏item 發布:2025-05-14 11:43:56 瀏覽:328
javawebeclipse編譯 發布:2025-05-14 11:35:24 瀏覽:938
可編程式控制制器試題 發布:2025-05-14 11:25:32 瀏覽:122
dsp混合編程 發布:2025-05-14 11:23:10 瀏覽:251