Toast if a component gains focus

0

I want to display a toast if the map view gets 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 it seems that just rolling the screen does not focus on the component. How to proceed?

    
asked by anonymous 13.10.2017 / 21:36

0 answers