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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:09:28+00:00 2026-06-06T04:09:28+00:00

I have a custom ListView with two button and I when I click either

  • 0

I have a custom ListView with two button and I when I click either button on any row I want to get the text label on the Listview and for now just popup a toast with it. So far nothing has worked I keep getting the last item in my array.

Here is a screen shot to give you a better idea of what i mean

enter image description here

Here is my Adapter subclass for my custom ListView

static final String[] Names = 
           new String[] { "John", "Mike", "Maria", "Miguel"};


class MyArrayAdapter extends ArrayAdapter<String> {
    private final Context context;      

    int which;

    public MyArrayAdapter(Context context, String[] pValues) {
        super(context, R.layout.main, pValues);
        this.context = context;
        values = pValues;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        rowView = inflater.inflate(R.layout.main, parent, false);
        TextView textView = (TextView) rowView.findViewById(R.id.label);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);
        Button call = (Button) rowView.findViewById(R.id.button1);
        Button chat = (Button) rowView.findViewById(R.id.button2);
        textView.setText(values[position]);


        // Change icon based on name
        s = values[position];           
        which = position;
        call.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                String name = values[which];
                Toast.makeText(CustomListView.this, name, Toast.LENGTH_SHORT).show();
            }
        });

        return rowView;
    }
}

Edit:

String name = textView.getText().toString();
RelativeLayout ll = (RelativeLayout)v.getParent();
textView = (TextView)ll.findViewById(R.id.label);
Toast.makeText(CustomListView.this, name,
Toast.LENGTH_SHORT).show();
  • 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-06T04:09:30+00:00Added an answer on June 6, 2026 at 4:09 am

    Easy to do:

        call.setOnClickListener(new OnClickListener() { 
            @Override 
            public void onClick(View v) { 
                RelativeLayout rl = (RelativeLayout)v.getParent();
                TextView tv = (TextView)rl.findViewById(R.id.label);
                String text = tv.getText().toString();
                Toast.makeText(CustomListView.this, text, Toast.LENGTH_SHORT).show(); 
            } 
        }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a custom listview with two rows of text in each item,
I have a custom list view which contains two text views and on button.
I have a problem now! I have custom ListView, there I have two TextView
I have two ItemsControls, one a ListView, and one a custom control I am
I have a listView with custom objects defined by the xml-layout below. I want
I have a listview with custom row having a textview and a clickable image
I have a listview with custom rows and that extends SimpleAdapter. Each row consist
I have a custom ListView with two TextViews , I have two string arrays
So I have a custom ListView object. The list items have two textviews stacked
I have a ListView which I've created a custom view for each row. My

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.