-2

I want to build a "goals" layout on my app, but, i want that every time user touches a badge, there appears a hint on it for 2 seconds, then dissapear. Otherwise, if user touches outside de hint, it will also dissappear.

Dani Roca
  • 11
  • 1
  • 6

2 Answers2

0

You need PopUpWindow.

  • You will find methods which will dismiss popup window if touched outside like this.

    mPopWindowInstance.setTouchInterceptor(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                mPopWindowInstance.dismiss();
                return true;
            }
            return false;
        }
    });
    
  • And you can use your own timers to dismiss it after any specified time.

Check the link below.

http://developer.android.com/reference/android/widget/PopupWindow.html

http://mrbool.com/how-to-implement-popup-window-in-android/28285

and as Micheal suggested. you can use Toasts to display some hints. But popup windows can be shown as hints exactly above the buttons getting clicked and can have animation style of popping up. Looks good from ui prospective.

Hope this helps

Rohit Sharma
  • 13,787
  • 8
  • 57
  • 72
0

I think you are looking for toast messages!

check this link: http://developer.android.com/guide/topics/ui/notifiers/toasts.html

Michael
  • 815
  • 1
  • 6
  • 23