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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:02:26+00:00 2026-05-22T15:02:26+00:00

I have an ImageView for which I wanted to implement the onClickListener. But when

  • 0

I have an ImageView for which I wanted to implement the onClickListener. But when I click on the image, nothing happens. Event the Logcat does not show any errors.

Following is my import statement:

import android.view.View.OnClickListener;

Following is my layout code for the image:

<ImageView android:id="@+id/favorite_icon" 
    android:src="@drawable/small_star"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|right" android:paddingTop="63sp"
    android:paddingRight="2sp"  />

Following is the code in my activity which defines the event handler for onClickListener:

ImageView imgFavorite = (ImageView) findViewById(R.id.favorite_icon);
imgFavorite.setClickable(true);
imgFavorite.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i(SystemSettings.APP_TAG + " : " + HomeActivity.class.getName(), "Entered onClick method");
                Toast.makeText(v.getContext(),
                        "The favorite list would appear on clicking this icon",
                        Toast.LENGTH_LONG).show();
            }
        });

Am I missing something?

  • 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-22T15:02:27+00:00Added an answer on May 22, 2026 at 3:02 pm

    Ok,

    I managed to solve this tricky issue. The thing was like I was using FrameLayout. Don’t know why but it came to my mind that may be the icon would be getting hidden behind some other view.

    I tried putting the icon at the end of my layout and now I am able to see the Toast as well as the Log.

    Thank you everybody for taking time to solve the issue.. Was surely tricky..

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

Sidebar

Related Questions

I have a class named CropImageView which is extended from ImageView . but the
I have a listview which includes 2 textviews and 1 imageview. Now, the image
I have a file selector (which works as needed) but I wanted to add
I have an imageview, which uses matrix to scale/drag an image. Now I want
I have an imageview in which I want an image to be set. My
I have image in a imageview which is placed in a scrollview., Zoom in
I have an imageview which is loading an image from the internet. I am
Kindda weird situation... I have an ImageView which has a click interaction associated with
I have an imageview which will have a fixed size: layout_width=100dip layout_height=50dip but the
I have an ImageView which will display an image from the web. I used

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.