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!!


Need Your Help

Make SearchView text entry disabled?

java android searchview

I was wondering if there was a way to temporarily make it so that SearchView temporarily cannot be used to type in but still seen. I'd rather do this than recreate different actionbars over and ove...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.