當前位置:首頁 » 安卓系統 » 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