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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:16:28+00:00 2026-05-24T16:16:28+00:00

when I make a custom view class and add a clickListener it fires anywhere

  • 0

when I make a custom view class and add a clickListener it fires anywhere on the screen I click, even where the custom view is not. If I use the same code with a button from a layout it only fires when I click the button not anywhere on screen. Any ideas how to just only listen for when my custom class is directly clicked?

button only fire when pressed

   Button b = (Button) findViewById(R.id.button1); 
   b.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
      Log.d(DEBUG_TAG, "button clicked");
   }
});

stroke object fires when you press anywhere on screen, even outside of stroke’s bounding box

    Stroke stroke = new Stroke(this);
    mainLayout.addView(stroke);
    stroke.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
      // fires on every screen click :>(
      Log.d(Main.DEBUG_TAG, this.toString()+"shape clicked");
   }
    });
  • 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-24T16:16:28+00:00Added an answer on May 24, 2026 at 4:16 pm

    I think your custom view just fills the whole screen. That’s why it reacts on every click on the screen. You need to make it smaller and everything will work fine.

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

Sidebar

Related Questions

I'm trying to make a custom view in Django admin. I'm reading from this
I want to make custom select from the database table using Linq. We use
The following code will make the View clickable, but I am wondering if this
I m developing a program that makes use of UIImagePicker custom class made by
I need to make custom text field which will format numeric values according to
I got the design (PSD) from client. Which should i choose to make custom
I want to make a custom ASP.NET control that is a subclasse of System.Web.UI.WebControls.Calendar
Trying to make a custom :confirm message for a rails form that returns data
I tried to make a custom pushpin for the Bing Maps silverlight control, but
I'd like to make some custom MenuHeaders in WPF so I can have (for

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.