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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:17:49+00:00 2026-06-14T21:17:49+00:00

I have a list view in my screen, every list item contains 2 text

  • 0

I have a list view in my screen, every list item contains 2 text views and one button.
On button click i want to take the list item selected index to get some data from a vector.

This is my List Custom Adapter.But i don’t know how to do that.

private class CustomAdapter extends ArrayAdapter<ServicesItems> {

    public CustomAdapter(Context context, int resource,
            int textViewResourceId, List<ServicesItems> objects) {
        super(context, resource, textViewResourceId, objects);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        TextView item = null;
        TextView description = null;
        Button subNowBtn;

        ServicesItems ii = getItem(position);

        if (null == convertView) {
            convertView = mInflater.inflate(
                    R.layout.list_of_servics_item_2, null);

            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        holder = (ViewHolder) convertView.getTag();
        // cat_name = holder.gettitle();

        Resources resources = getResources();

        ServicesItems bean1 = (ServicesItems) servicesVector
                .elementAt(position);

        String cat_name_str = bean1.getService_name().toString();
        String descreption = bean1.getDescription().toString();


        item = holder.getItem();
        item.setText(bean1.getDescription());

        description = holder.getDescription();
        description.setText(bean1.getService_name());

         subNowBtn=holder.getSubButton();

        return convertView;
    }

    private class ViewHolder {
        private View mRow;
        private TextView description = null;
        private TextView item = null;
        private Button sub = null;

        public ViewHolder(View row) {
            mRow = row;
        }

        public TextView getDescription() {
            if (null == description) {
                description = (TextView) mRow
                        .findViewById(R.id.category_tv);
            }
            return description;
        }

        public TextView getItem() {
            if (null == item) {
                item = (TextView)       
           mRow.findViewById(R.id.descreption_tv);
            }
            return item;
        }

        public Button getSubButton(){
            if(null==sub){
                sub=(Button)findViewById(R.id.subscribe_now_btn);


            }
            return sub;
        }

    }

}
  • 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-14T21:17:51+00:00Added an answer on June 14, 2026 at 9:17 pm

    In your Adapter try this:

    @Override
    public View getView(final int position, View convertView, ViewGroup parent)
    {
        View row = convertView;
        YourWrapper wrapper = null;
    
        if (row == null)
        {
            row = inflater.inflate(R.layout.layout, parent, false);
            wrapper = new YourWrapper (row);
            row.setTag(wrapper);
        }
        else
            wrapper = (YourWrapper) row.getTag();
    
        wrapper.getButton().setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                // What you want
            }
        });
    
        return row;
    }
    

    EDIT

    Your wrapper class:

    public class YourWrapper
    {
        private View base;
        private Button button;
    
        public YourWrapper(View base)
        {
            this.base = base;
        }
    
        public Button getButton()
        {
            if (button == null)
            {
                button = (Button) base.findViewById(R.id.your_button);
            }
            return (button`);
        }
    }
    

    Change sub=(Button)findViewById(R.id.subscribe_now_btn); into sub=(Button) mRow.findViewById(R.id.subscribe_now_btn);

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

Sidebar

Related Questions

On my screen I have a list view and a button. my list has
In my application, I have list view. Selecting another item in it, triggers an
I have a list view with 10 columns and I want each row to
This one is weird. I have a list view that is a part of
I have two views of some data: a list view (a ListBox now, but
I have an app that populates list views when a view is created. I
I have created a list view which contains a list of images defined by
I have a list view. How can I show the item of the listView
I have a vertical LinearLayout which has a list view and one ImageView at
I have list view and its adapter stored as global variables. I am not

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.