Toast if a component gains focus

Asked

Viewed 43 times

0

I want to display a Toast if the map view gains focus. What I’ve been able to do so far is:

        mapView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                Toast.makeText(getApplicationContext(), "Tem o foco", Toast.LENGTH_SHORT).show();
            }
        }
    });

But apparently, just scrolling the screen does not give the focus to the component. How to proceed?

  • What exactly do you want to know?

  • When scrolling the screen and the user see the mapview, show a Toast

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.