簡體   English   中英

是否顯示文字建議視圖時如何收聽

[英]How to listen when the text suggestion view is displayed or not

我有一個登錄活動,其中有3個Edittext,一個登錄按鈕和位於底部的2個單選按鈕。

我的要求是,在出現文本建議視圖時隱藏底部的單選按鈕,並在顯示時顯示它。

我的活動是這樣的

在此處輸入圖片說明在此處輸入圖片說明

有沒有聽力方法,是否顯示文本建議視圖?

我不確定任何可以告訴您文本建議等方法的方法。

但是是的,我們可以做到!

我建議您做的是一個小技巧,以檢查鍵盤是否顯示建議。

在我的項目中,我正在玩鍵盤東西。

因此,當第一次在屏幕上出現鍵盤時,我們可以獲取鍵盤高度,當您開始輸入提示信息時,您的鍵盤高度將被更改,這樣您可以檢查提示是打開還是關閉。

所以在這里,我分享了我的代碼,您可以使用該代碼來計算鍵盤高度。

/**
     * This method is to calculate Virtual Keypad Height
     * 
     * 
     * @param no params
     *            
     * @return no return value
     * @author Ramdhan
     */
    private void getKeypadHeight() 
    {
        Log.v("RDC", "Keypad Height");
        final View activityRootView = findViewById(R.id.activityRoot);
        activityRootView.getViewTreeObserver()
        .addOnGlobalLayoutListener(new OnGlobalLayoutListener() 
                {
                    @Override
                    public void onGlobalLayout() 
                    {
                        Log.v("RDC", "onGlobalLayout");

                        Rect r = new Rect();
                        activityRootView.getWindowVisibleDisplayFrame(r);

                        int screenHeight = activityRootView.getRootView()
                                .getHeight();
                        int heightDifference = screenHeight
                                - (r.bottom - r.top);
                        Log.d("Keyboard Size", "Size: " + heightDifference);

                        Display display = getWindowManager()
                                .getDefaultDisplay();
                        int width = 0;
                        int height = 0;
                        if (android.os.Build.VERSION.SDK_INT >= 13) {
                            Point size = new Point();
                            display.getSize(size);
                            width = size.x;
                            height = size.y;
                        } else // for lower versions
                        {
                            width = display.getWidth();
                            height = display.getHeight();
                        }
                        Log.v("Screen Size", "Screen Width =" + width
                                + "and height is=" + height);

                        if (heightDifference > 100) {
                            Log.d("Keyboard Size", "It is keypad");

                            // new OneTouchShareActivity().updateUIComponents(
                            // height, heightDifference);

                        }
                    }
            });
    }

請!! 讓我知道是否需要更多幫助。

我有想法如何做到這一點。 很高興分享!

AFAIK沒有這樣的方法來獲取鍵盤建議。 但是你可以做一件事。 您可以在鍵盤出現在屏幕上時隱藏RadioButton ,並在鍵盤隱藏時使其再次可見。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM