第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

EditText 完成后軟鍵盤再次打開

EditText 完成后軟鍵盤再次打開

千萬里不及你 2023-02-23 17:39:57
所以我有custom alert dialog一個EditText。每當我點擊一個按鈕進行確認,或者如果我點擊軟鍵盤自己的完成按鈕,我已經(jīng)對應(yīng)用程序進行了編程以關(guān)閉對話框。但是由于某些奇怪的原因,soft-keyboard在關(guān)閉警報對話框后仍然打開...最后的這段代碼 buttonConfirm是我試圖解決這個問題的。出于某種原因,代碼不適用于按鈕本身,但代碼確實適用于軟鍵盤中的完成按鈕buttonConfirm.setOnClickListener(new     View.OnClickListener()    {..............    .................         closeKeyboard();         Handler handler = new Handler();         handler.postDelayed(new Runnable() {         @Override         public void run() {             dialog.dismiss();         }     }, 100); // 5000ms delay}//This is the code for the done-button in the `soft keyboard`textinputEdit.setOnEditorActionListener(new OnEditorActionListener() {        @Override        public boolean onEditorAction(TextView v, int actionId, KeyEvent event){         if(actionId==EditorInfo.IME_ACTION_DONE){              buttonConfirm.performClick();         }         return false;       }});那么,為什么在直接按下按鈕時它會起作用而不是按鈕本身呢?這對我來說很奇怪.. 任何人都知道這到底是怎么回事?:(
查看完整描述

2 回答

?
冉冉說

TA貢獻1877條經(jīng)驗 獲得超1個贊

單擊完成按鈕時,調(diào)用hideSoftInputFromWindow方法 -

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);


查看完整回答
反對 回復(fù) 2023-02-23
?
函數(shù)式編程

TA貢獻1807條經(jīng)驗 獲得超9個贊

public void hideSoftKeyboard(Context context, View view) {

        try {

            InputMethodManager inputMethodManager =

                    (InputMethodManager) context.getSystemService(

                            Activity.INPUT_METHOD_SERVICE);

            inputMethodManager.hideSoftInputFromWindow(

                    view.getWindowToken(), 0);

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

用法


textinputEdit.setOnEditorActionListener(new OnEditorActionListener() {

                    @Override

                    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

                    if(actionId==EditorInfo.IME_ACTION_DONE){

                        buttonConfirm.performClick();

                        hideSoftKeyboard(YourActivityName.this,textinputEdit);

                    }

                    return false;

                }

            });


查看完整回答
反對 回復(fù) 2023-02-23
  • 2 回答
  • 0 關(guān)注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號