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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:55:23+00:00 2026-06-04T07:55:23+00:00

I have a ListView with an image over the right hand side. and I

  • 0

I have a ListView with an image over the right hand side. and I wanted to perform a onClick listener event by clicking the image on the ListView. Please see the image for reference.

enter image description here

I know basic OnClick listener Implementations, but this seems to be a little tricky to me 😛

Forgot to mention, by clicking the actual ListView will shootup a new activity, so I need to maintain both the schemas.

 listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
            eventsData.remove(id);
            cursor.requery(); 
        }

    });   

The code above perform a deletion by clicking on any list element eventsData.remove(id); is a database helper for executing this task. like I said now I need a method to perform this same process juts by clicking the image, not the entire list element, I want the list element to do some other action later on.

I hope now I’m clear a bit.


The Solution:

If anybody come across the same sort of situation then here is the complete code for the adapter.

 class CustomAdapter extends ArrayAdapter<String> {
 CustomAdapter() {
  super(Activity.this, R.layout.row, R.id.label, items);
}

public View getView(final int position, View convertView,
                    ViewGroup parent) {
  View row=super.getView(position, convertView, parent);
  deleteImg=(ImageView)row.findViewById(R.id.icon);

  deleteImg.setImageResource(R.drawable.delete);      
  deleteImg.setOnClickListener(new OnClickListener() {
      String s = items[position];
    @Override
    public void onClick(View v) {
        Toast.makeText(context, s, Toast.LENGTH_SHORT).show();          
    }
});

  return(row);
}

}

I know the coding is a bit crappy so bear with me, I just want to show the actual process that’s it.

It’s working for me 🙂

  • 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-04T07:55:25+00:00Added an answer on June 4, 2026 at 7:55 am

    You should do it In your Adapter not in Activity.

    yourImg.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View v) {
            // things you want to do 
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview with an image and a textview and I am applying
I have a listview with custom row having a textview and a clickable image
I have fetched images and text as listview from database.now on clicking the particular
I have a listview which includes 2 textviews and 1 imageview. Now, the image
I have one listview.which contain one image ,text and one button .i had creted
While working over listView I have came across a trouble situation. Actually I am
I have a lazy-loading ListView populated with images gotten over the network. The list
I have my ListView with image background (it's actually a fragment) but still i
I have a ListView where each row has two webviews side by side, taking
I have a ListView that has one image and two lines of texts 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.