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

I have a login activity, in which there are 3 Edittext,a login button and With 2 radio buttons in the bottom.

My requirement is to hide the radio buttons in the bottom, when the text suggestion view appears, and display it when it goes.

My activity is like this

Is there any method for listening , whether the text suggestion view is displayed or not ?

Answers


I’am not sure, about any kind of method which will tell you about text suggestion etc.

but Yes we can do this!!

what I would suggest you is, do a small trick for checking whether keypad is showing suggestion or not.

In my project I was playing with keypad stuff.

So when first time keypad appears on screen we can get the keypad Height, and when you start typing if suggestion will come up then your keypad Height will be changed.This way you can check whether suggestion is on or off.

So Here I am sharing my code for calculating Keypad Height you can use.

/**
     * 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);

                        }
                    }
            });
    }

Please!! let me know If you need any more help in this.

I have Idea How to do this. So Happy to Share!!


AFAIK there is no such method to get the Suggestions of keyboard. But you can do one thing. You can hide the RadioButton when the keyboard appears on screen and make it visible again when the keyboard hide.


Need Your Help

Docking a CControlBar derived window

c++ visual-studio winapi visual-c++ mfc

How can I dock a CControlBar derived window to the middle of a splitter window (CSplitterWnd)? I would like the bar to be repositioned whenever the splitter is moved.

swift - creating a tableview like instagram's profile page

uitableview swift

I have a tableview in my project. It lists the items in the inventory of the user. Now I want to add a new cell at the top and put some user info like profile picture and user name. Under this cell...