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 6149467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:27:19+00:00 2026-05-23T19:27:19+00:00

I have a class extends ViewGroup and want to get every MotionEvent from it.

  • 0

I have a class extends ViewGroup and want to get every MotionEvent from it. So far I have this:

class TestViewGroup extends ViewGroup {
     public TestViewGroup(Context context) {
         super(context);
     }

     @Override
     public boolean onTouchEvent(MotionEvent event) {
         Log.d("TestViewGroup", "X: " + (int)event.getX() + " Y: " + (int)event.getY());
         return true;
     }
 }

The onTouchEvent(MotionEvent event) method is able to capture a MotionEvent every time I place my finger on the screen. But if I move my finger around the screen while my finger is still down, it won’t continue to trace the coordinates of my finger. I know that in a class that extends a View, it is possible to keep tracing the finger as it moves through the View. I’m just wondering how it is possible to apply the same idea to a ViewGroup.

  • 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-05-23T19:27:20+00:00Added an answer on May 23, 2026 at 7:27 pm

    I implemented a very simple ViewGroup class and copied your code, the onTouchEvent worked fine

    The only thing I did differently was implement all of the constructors, though in general I would also call the super for the onTochEvent class that did not seem to make a difference.

    So I am wondering if there is any code/xml you are leaving out that might make a difference?

    Captures all touch events in emulator and on device, pretty much just like yours with the exception of the constructors.

    public class customViewGroup extends ViewGroup {
    
        public customViewGroup(Context context) {
            super(context,null,0);
       }
    
        public customViewGroup(Context context, AttributeSet attrs) {
            super(context, attrs,0);
    
        }
    
        public customViewGroup(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        @Override
        protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) {
    
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            Log.d("bThere", "X: " + (int)event.getX() + " Y: " + (int)event.getY());
            return true;//super.onTouchEvent(event);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is what I have: class Calendar extends CI_Controller { public $extension; function __construct()
I have class where I draw image. This is code: public class CanvasdrawActivity extends
I have a class defined as public class viewGroups extends ListActivity Somewhere in the
I have a class extends NamedParameterJdbcDaoSupport. well this superclass has a final setDataSource method
I have class A which extends the Activity class. This class is in package
I have a class that extends AsyncTask , which fetches the gps cordinates from
I have a custom list adapter. Here it is: public class FilesAdapter extends ArrayAdapter<PutioFileLayout>
I have a Fragment which Extends SupportMapFragment. public class PlaceMapsFragment extends SupportMapFragment { private
I have class Meat extends Food { $var = Food::foodFunction… } I need to
i have a class extends asynctask private class taskMK extends AsyncTask<Void,Void,JSONObject>{ String url; JSONObject

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.