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

  • Home
  • SEARCH
  • 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 7524921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:11:34+00:00 2026-05-30T03:11:34+00:00

I have made a ScrollView and filled it with ImageViews that have OnClickListeners attached

  • 0

I have made a ScrollView and filled it with ImageViews that have OnClickListeners attached to them, but now when I try to scroll the ScrollView, it seems that the OnClickListeners get in the way and don’t give a smooth scroll.

Is there a way to fix that, other then using a ListView instead of ScrollView?

Thanks!

  • 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-30T03:11:35+00:00Added an answer on May 30, 2026 at 3:11 am

    You don’t have to have an OnClickListener for each ImageView.

    The callback definition is

    public abstract void onClick (View v)
    

    where v is the view that was clicked.

    Depending on what you want to do, you can identify the specific view or not. IF you just want to do something generic, (for example, applying a tint), then this is very straightforward

    ...
    public void onClick(View v) {
        ImageView iv = (ImageView) v;
        iv.setTint(Color.BLUE); // Or whatever generic operation you want
    } 
    

    If you need to identify the view specifically, e.g. it’s part of an XML menu, then I usually use the itemID to identify it

    ...
    public void onClick(View v) {
        int id = v.getId();
        switch (id) {
            case R.id.save:
              //do stuff
              break;
            case R.id.open:
               //do stuff
               break;
        }
    } 
    

    If the views aren’t static, then you can use the setTag() and getTag() methods to uniquely identify (and associate useful data!) with each view:

    ...
    public void onClick(View v) {
        // the MyViewInfo object was associated with the view somewhere else, presumably when the view was created
        MyViewInfo info = (MyViewInfo) v.getTag();
        File datafile = info.getFileName();
        ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made some custom attached properties that enable me to create a pop
I have made some code that makes powerpoint and excel work together. And I
I have made an normal form that you can enter a user´s fullname in
I have made an application that can render and save a given element. With
I have made a Linux CUI app that communicates between processes via Message-quene. There
I have a question that might seem basic but can't figure it out. Basic
I have uiimageviews as subviews for uiscrollview. I made my uiviewcontroller resize the scrollview
I have made a SVG image, or more like mini application, for viewing graphs
I have made some code which exports some details of a journal article to
I have made a custom UserControl i Vb.net (windows application). How can I add

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.