-1

I have a question concerning the views in android studio:

Is there a method which returns a Boolean to indicate if a "view is on a longclick"

Bazouk55555
  • 557
  • 6
  • 24
  • 1
    Possible duplicate of [Android: long click on a button -> perform actions](https://stackoverflow.com/questions/4402740/android-long-click-on-a-button-perform-actions) – krishan Aug 06 '17 at 04:19

1 Answers1

0

By setting an onClickListener on it, then taking action when the listener's onClick() method is called, e.g.:

View btnView = view.findViewById(R.id.btnView);
btnView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        // do something
    }
});
Edmund Johnson
  • 709
  • 8
  • 15
  • Sorry I didn't formulate my question well: I wanted to ask if there is a method which returns a Boolean to indicate if a "view is on a longclick" – Bazouk55555 Aug 05 '17 at 21:19
  • Do you mean if the user is currently clicking on the view? If so, have a look at things like View.isInTouchMode(), isActivated(), isFocused(), isPressed() and isSelected(). I can't say which is the right one in your situation though. – Edmund Johnson Aug 07 '17 at 15:57