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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:40:53+00:00 2026-05-27T21:40:53+00:00

I have an Activity with a layout containing a custom ImageView and a few

  • 0

I have an Activity with a layout containing a custom ImageView and a few other views (a ListView and a couple other TextViews). Depending on where the user touches the ImageView, I need to change the contents of the ListView and the TextViews. I have an onTouchEvent listener working fine in the ImageView class, but somehow I need to signal the Activity class that the touch event happened in the ImageView and pass it some data…then the Activity can properly adjust all the other views.

I thought about trying to return “false” from the ImageView‘s onTouchEvent handler, thus letting the event matriculate up to the ImageView’s parent view, but I don’t think it has a parent view…just a parent ViewGroup (LinearLayout).

This feels like a design issue to me, but I’m not sure.

Thanks in advance for any suggestions.

  • 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-27T21:40:54+00:00Added an answer on May 27, 2026 at 9:40 pm

    I don’t think there’s a built-in way to do this. Write your image view class to all for a call-back to be registered after it changes its content. Then in the activity’s onCreate method, retrieve the image view and register the activity as the call-back object. When the image view finishes handling the touch event, it can just invoke the call-back method.

    Here’s a sketch of how this might work:

    public class MyImageView extends ImageView {
        public interface OnImageChangedListener {
             public void imageChanged(MyImageView view);
        }
    
        private OnImageChangedListener mChangeListener;
    
        public void setOnImageChangedListener(OnImageChangedListener listener) {
            mChangeListener = listener;
        }
    
        // inside your OnTouchListener:
            public boolean onTouch(View view, MotionEvent event) {
                // make updates, then, if warranted:
                if (mChangeListener != null) {
                    mChangeListener.imageChanged(MyImageView.this);
                }
            }
    

    Then just have your activity declared to implement MyImageView.OnImageChangedListener and call imageView.setOnImageChangedListener(this) after finding the image view (probably using findViewById).

    Obviously, you can save some typing by shortening the method names. More importantly, you can, if it would be useful, add additional arguments to the call-back method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity containing two imagebuttons. If the user clicks back an alertDialog
I have activity with three GrindViews. I fill these views with custom SimpleCursorAdapters. In
In my example activity, I have - a ListView containing - multiple HorizontalScrollView containing
I have ImageViews and TextViews in my layout (activity is inside a Tab), and
I have Activity with ListView inside it and in the onCreate method of the
I have an activity that has a TabHost containing a set of TabSpecs each
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have an activity that contains several user editable items (an EditText field, RatingBar,
I have an activity with two buttons, start and stop. If the user press
I have the following problem: I have an Activity where a user can start

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.