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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:03:03+00:00 2026-06-02T06:03:03+00:00

I defined onTouchEvent(MotionEvent event) to receive touch events for imageview. I am using multiple

  • 0

I defined onTouchEvent(MotionEvent event) to receive touch events for imageview. I am using multiple imageviews and i have to find for which imageview I have received touch event.
Is it possible to get imageview inside onTouchEvent?

public void createImageViews()
{
  int i = 0;

  imageArray[0] = (ImageView)findViewById(R.id.image1);
  imageArray[1] = (ImageView)findViewById(R.id.image2);
  imageArray[2] = (ImageView)findViewById(R.id.image3);
  imageArray[3] = (ImageView)findViewById(R.id.image4);
  imageArray[4] = (ImageView)findViewById(R.id.image5);
  imageArray[5] = (ImageView)findViewById(R.id.image6);

  for (i = 0; i < count; i++)
  {
    imageArray[i].setOnTouchListener(this);
  } 
}
 public class Touch extends Activity implements OnTouchListener, AnimationListener { }

I have tried using

 public boolean onTouch(View v, MotionEvent event) { } but not receiving the touch events.

After starting the animation on imageview I did not observe touch events in onTouch() and getting touch events in onTouchEvent() . imgArray[g_animCount].startAnimation(movArray[g_animCount]);

  • 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-02T06:03:05+00:00Added an answer on June 2, 2026 at 6:03 am
    use the below sample code snippet::::
    
        public class MyImageView extends Activity implements OnTouchListener{
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.lay_name);        
            int i = 0;
            imageArray[0] = (ImageView)findViewById(R.id.image1);
            imageArray[1] = (ImageView)findViewById(R.id.image2);
            imageArray[2] = (ImageView)findViewById(R.id.image3);
            imageArray[3] = (ImageView)findViewById(R.id.image4);
            imageArray[4] = (ImageView)findViewById(R.id.image5);
            imageArray[5] = (ImageView)findViewById(R.id.image6);
    
            for (i = 0; i < count; i++)  {
                imageArray[i].setOnTouchListener(this);
             } 
    
    
        }
    
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            switch(v.getId()){
            case R.id.image1:
            //your stuff
            break;
            case R.id.image2:
            //your stuff        
            break;
            case R.id.image3:
            //your stuff
            break;
            case R.id.image4:
             //your stuff
            break;
            case R.id.image5:
             //your stuff
            break;
            case R.id.image6:
             //your stuff
            break;
            }
        }
    

    }

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

Sidebar

Related Questions

I have a large custom ImageView with regions defined as hotspots. When a user
I defined two panels in viewport: a main panel which is non-floating, the other
I defined a custom routed event with the following constructs (names changed): public class
I have a ScrollView that contains a complex LinearLayout with various elements, among which
I have this Selector defined: <selector xmlns:android=http://schemas.android.com/apk/res/android> <!-- PRESSED --> <item android:state_pressed=true android:drawable=@drawable/backarrow_blueshiny />
Defined a SQL Server, which only user x (in the domain) is allowed to
I defined a Controller to force authentication by using the [Authorize] attribute. When a
I have a ScrollView defined like this: <ScrollView xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/scrollv android:layout_width=wrap_content android:layout_height=wrap_content> <com.test.myview android
i´ve defined an array which contents 4 UIView objects which were already defined NSArray
I defined a variable which will get user's input: var input = USER_INPUT; then,

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.