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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:44:44+00:00 2026-06-01T13:44:44+00:00

This is the class I want to implement the onClickListener in: private void updateUserListView(DatabaseHandler

  • 0

This is the class I want to implement the onClickListener in:

private void updateUserListView(DatabaseHandler dbh) {
    List<User> users = dbh.getAllUsers();
    ListView listView = (ListView) findViewById(R.id.userslistview);
    listView.setAdapter(new UserArrayAdapter(BeerFriendActivity.this, users));      
}

The adapter code is:

public class UserArrayAdapter extends ArrayAdapter<User> {
private final Context context;
private final List<User> values;

public UserArrayAdapter(Context context, List<User> values) {
    super(context, R.layout.userrow, values);
    this.context = context;
    this.values = values;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final int pos = position;
    final Context con = context;
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.userrow, parent, false);
    Button button = (Button) rowView.findViewById(R.id.userrowbutton);
    TextView textView = (TextView) rowView.findViewById(R.id.userrownametext);
    textView.setText(values.get(position).getName());

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(context,BeerSearchActivity.class); 
            Bundle b = new Bundle();
            b.putInt("id", values.get(pos).getId());
            myIntent.putExtras(b); //Put your id to your next Intent
            con.startActivity(myIntent);
        } 
    });

    User user = values.get(position);
    return rowView;
}}

I have tried implementing the clicker, but all I get is a bunch of errors. I’ve read many tutorials and similar questions, but none of the answers seem to fit my situation or I’m not quite understanding them. Any help would be much appreciated!

  • 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-01T13:44:45+00:00Added an answer on June 1, 2026 at 1:44 pm

    ListView isn’t really set up to have clickable controls in it, the onClick() methods consume the touchEvent instead of the row. There is a workaround though, wherein you specify a custom callback in XML for your button or other clickable element, like in this example.

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

Sidebar

Related Questions

given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
What I want is this behavior: class a: list = [] x = a()
Situation I want to implement the Composite pattern: class Animal { public: virtual void
I have subclassed a UITableViewCell and within this class I want to get it's
I have this class which I want to pass around Windows as LPARAM parameter.
I want to serialize this class: public class CarDisplay { public string Name {
i want to serialize this class, to store it on the sdcard of the
I want to do something like this: class Cls { function fun($php) { return
With Django models, I want to achieve this: class Foo(models.Model): name = models.CharField(max_length=50) #wrapping
I have an issue regarding Sendkeys Class, as i want to use this class

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.