Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9242893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:41:04+00:00 2026-06-18T08:41:04+00:00

In my application I got a requirement to use both click and drag events

  • 0

In my application I got a requirement to use both click and drag events on the same textView.

I have written the following code:

... }
    switch(event.getAction()) {
        case MotionEvent.ACTION_UP:
//            TextDialog.setVisibility(View.VISIBLE);
            break;
        case MotionEvent.ACTION_DOWN: {
            disallowTouch(parent, true);
            int downX = (int)event.getX();
            int downY = (int)event.getY();
            return false; // allow other events like Click to be processed
        }
        case MotionEvent.ACTION_MOVE:
            int x = (int)event.getRawX();
            int y= (int)event.getRawY();

            layoutParams.leftMargin = x - 50;
            layoutParams.topMargin = y - 70;
                                       
            tvText.setLayoutParams(layoutParams);
            break;
        default:
            break;
    }
    return true;
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    TextDialog.setVisibility(View.VISIBLE);
}

But only ACTION_MOVE is working. The onClick event is not getting fired.

I just want to display a dialog when clicking on the TextView.

How can I achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:41:05+00:00Added an answer on June 18, 2026 at 8:41 am

    Use setOnTouchListener and setOnClickListener simultaneously

    in onTouch:

    public boolean onTouch(View v, MotionEvent event) {
        ViewParent parent = v.getParent();
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN: {
            disallowTouch(parent, true);
            downX = event.getX();
            downY = event.getY();
            return false; // allow other events like Click to be processed
        }
    }
    
    private void disallowTouch(ViewParent parent, boolean isDisallow) {
        if (parent != null) {
            parent.requestDisallowInterceptTouchEvent(isDisallow);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing application (with MySQL DB). I just got a new requirement
I have got a requirement from a client. They need three blogging web application
I have written some code that makes use of an open source library to
On a server running a Qt application I got the following error, as soon
In the WIX setup I've got, when upgrading the application I have set a
My application has got several pages. On some pages I have given a back
Now there is a new requirement. I have got some adhoc work at hand.
I have an Intranet ASP.NET application which is sometimes slow to respond. My requirement
So I have a WPF application using the MVVM pattern (Caliburn.Micro). I got the
Due to some certain requirement, I've got to use a single svc for multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.