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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:15:42+00:00 2026-05-26T19:15:42+00:00

I have a simple ArrayAdapter. I want to set up a listener for every

  • 0

I have a simple ArrayAdapter. I want to set up a listener for every row click of my list such that a new Activity opens. How would I do that? My ArrayAdapter code –

public class CountryListAdapter extends ArrayAdapter<String> {
private final Activity context;
private final ArrayList<String> names;

public CountryListAdapter(Activity context, ArrayList<String> names) {
    super(context, R.layout.rowlayout, names);
    this.context = context;
    this.names = names;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = context.getLayoutInflater();
    View rowView = inflater.inflate(R.layout.rowlayout, null, true);
    TextView textView = (TextView) rowView.findViewById(R.id.label);
    textView.setText(names.get(position));
    return rowView;
}
  • 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-26T19:15:43+00:00Added an answer on May 26, 2026 at 7:15 pm

    Assuming you are using a ListActivity implementing OnItemClickListener
    you could use this code:

    ArrayAdapter<Object> ad = new ArrayAdapter<Object>(this,
                    android.R.layout.simple_list_item_checked, items);
            setListAdapter(ad);
            ListView list = getListView();
            list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            //list.setItemChecked(0, true);
            list.setOnItemClickListener(this);
    

    EDIT:
    Otherwise, if you don’t extend ListActivity, have a listview in your layout and replace ListView list = getListView() with something like ListView list = findViewById(R.id.listView). Replace list.setOnItemClickListener(this) with

    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spinner set up like this: ArrayAdapter<String> states = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
I have a simple list of strings that I populate into an Adapter per
I have a simple listview and listadapter setup as follows: listAdapter = new ArrayAdapter<MyDomainObject>(this,
I want to make a simple app that shows a list of contacts (name,
I have following goal: From a list in main activity that extends ListActivity, I
I have simple win service, that executes few tasks periodically. How should I pass
I have simple WinForms application where modifying Windows Registry. The problem is that in
I have a lisview that I want to add images to. The examples that
I have a ListView of items that need to be checkable/uncheckable. I have set
I created one simple list view. i have two list view, my 1st list

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.