Ajn
Ajn

Reputation: 583

Detecting touch by user at any point of time

I have a child view in my parent view. Now I am using animation to show child view for 10 sec and hide it after that. I want to show the child view even after 10 sec only if user touches it while animating. So how can I determine if the child view is touched by user or not? Does android provide any API to determine if view is touched by user at any instance of time?

Upvotes: 0

Views: 208

Answers (1)

colegu
colegu

Reputation: 370

You can set the "clickable" property to true and setOnClickListener(). like this:

exampleView.setOnClickListener( new OnClickListener() {
        @Override
        public void onClick(View v) {
            //TODO
        }
    });

You can also use the setOnTouchListener for more information on the "click".

Take a look here.

Upvotes: 2

Related Questions