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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:50:56+00:00 2026-05-25T05:50:56+00:00

i am trying to implement list view that has one click-able image View in

  • 0

i am trying to implement list view that has one click-able image View in each row, for this I have created custom Adapter and override all its methods. Now my problem is that
when i click this image view without clicking that row it is not functioning properly my code is below

protected void onListItemClick( ListView l, View v, final int position, long id) {

    super.onListItemClick(l, v, position, id);

     RowData rowObject = (RowData) l.getItemAtPosition(position);
     contactId= rowObject.getTextId(); 

//contactId gives the position of the row clicked in the list view.

     Log.e("on item clicked", contactId.toString());

     ImageView nextView = rowObject.getImageobject();
     nextView.setClickable(true);
     nextView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
                // TODO Auto-generated method stub
            Log.i("Value of row id", String.valueOf(position));
                Intent myintent = new Intent(v.getContext(),Info.class);
                myintent.putExtra("ContactId", contactId);
                v.getContext().startActivity(myintent);

        }
    });

here if i click on the row first and then image view then it is working fine. But if i click on image view without clicking on the row (i.e., without selecting the row), then it takes the position of last row clicked.

please help 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-05-25T05:50:56+00:00Added an answer on May 25, 2026 at 5:50 am

    ok finally digging so much in list view i got a solution by own,and that isthe getView method of custom adaptor,now whenever i click the image View the (int position)argument of getview gives the position of the row that was clicked.here i my code whitch i implemented later.

    private class CustomAdapter extends ArrayAdapter<RowData> {
        public CustomAdapter(Context context,int resource,int textViewResourceId,List<RowData> objects) {
            super(context, resource, textViewResourceId, objects);
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder = null;
            TextView Name     = null;
            TextView JobTitle   = null;
            ImageView Emailimage = null;
            ImageView Phoneimage = null;
            ImageView nextView = null;
            RowData rowData   = getItem(position);
    
            if(null == convertView){
                mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = mInflater.inflate(R.layout.contact_found_list_item_row, null);
                holder = new ViewHolder(convertView);
                convertView.setTag(holder);
            }
    
            String positionId = String.valueOf(position);
            holder = (ViewHolder) convertView.getTag();
            Name = holder.gettitle();
            Name.setText(rowData.mTitle);
            JobTitle = holder.getdetail();
            JobTitle.setText(rowData.mDetail);                                                     
            Emailimage=holder.getImage();
            Emailimage.setImageResource(rowData.phoneId);
            Phoneimage = holder.getphoneImage();
            Phoneimage.setImageResource(rowData.emailId);
            nextView = holder.getNextViewObject();
            nextView.setTag(positionId);
            nextView.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    ImageView iv = (ImageView)v;
                    String rowid = (String)iv.getTag();
                    Intent myintent = new Intent(v.getContext(),Info.class);
                    myintent.putExtra("ContactId", rowid);
                    v.getContext().startActivity(myintent);
                }
            });
    
            return convertView;
        }
    
        private class ViewHolder {
            private View mRow;
    
            private TextView Name   = null;
            private TextView JobTitle = null;
            private ImageView Emaillogo = null; 
            private ImageView phonelogo = null;
            private ImageView nextViewlogo = null;
    
            public ViewHolder(View row) {
                mRow = row;
            }
    
            public TextView gettitle() {
                if(null == Name){
                    Name = (TextView) mRow.findViewById(R.id.txtfirstname);
                }
                return Name;
            }     
    
            public TextView getdetail() {
                if(null == JobTitle){
                    JobTitle = (TextView) mRow.findViewById(R.id.txtjobtitle);
                }
                return JobTitle;
            }
    
            public ImageView getImage() {
                if(null == Emaillogo){
                    Emaillogo = (ImageView) mRow.findViewById(R.id.emaillogo);
                }
                return Emaillogo;
            }
            public ImageView getphoneImage(){
                if(null == phonelogo){
                    phonelogo = (ImageView) mRow.findViewById(R.id.mobilelogo);
                }return phonelogo;
            }  
            public ImageView getNextViewObject(){
                if(null == nextViewlogo){
                    nextViewlogo = (ImageView)mRow.findViewById(R.id.nextbutton);
                }return nextViewlogo;
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set On Click Listener on the List view. I have
I currently have a simple list view adapter that holds two rows of text.
I am trying to implement following scenario in the IPad environment. I have list
In my Rails 3 app, I have a list of questions. Each question has
I have an app that has a viewflipper to keep tabs in view at
Afternoon people! I'm trying to implement a list of counties on my Compact Framework
I'm trying to implement a mailing list system for my application. I'm currently using
I'm trying to implement my own List system in Java. the List class file
I'm trying to implement a linked list but get an error when compiling: intSLLst.cpp:38:
I'm trying to implement a link list which stores the city name (though you

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.