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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:14:17+00:00 2026-06-09T08:14:17+00:00

I have a button along with the List View in XML The Button is

  • 0

I have a button along with the List View in XML

The Button is for new contact and the list is for the List of Contacts.
1.How to use ArrayAdapter/OnListItemClick on this List View ?

setListAdapter(new ArrayAdapter<String>(Contacts.this, R.id.ListView));

Is This declaration correct ?

2.Is this method correct ?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <Button
        android:id="@+id/bAddContact"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="ADD CONTACT" />

    <ListView
        android:id="@+id/ListView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>
  • 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-09T08:14:19+00:00Added an answer on June 9, 2026 at 8:14 am

    Try this to display simple list

        String [] names = 
        { "a" , "b", "c", "d", "e", "f", "g", "h", "i", "j",
                "a1" , "b1", "c1", "d1", "e1", "f1", "g1", "h1", "i1", "j1",
                "a2" , "b2", "c2", "d2", "e2", "f2", "g2", "h2", "i2", "j2",
                "a3" , "b3", "c3", "d3", "e3", "f3", "g3", "h3", "i3", "j3","j4"
        }; 
    
         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, names );
         yourList.SetListAdapter(adapter);
    

    This is the way to use adapter.And for getting selected item of listView try this.

        listView.setOnItemClickListener(new OnItemClickListener() {
    
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
         long arg3) {
                 // TODO Auto-generated method stub
            String  getSelectedItemOfList = yourList.get(pos); // here you can get selected item.
         }
       });
    

    I think this is what you want. 🙂

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

Sidebar

Related Questions

I have this application with a list box. When a button is clicked, certain
I have button in my application that opens android contact application for choose contact
I have a repeater with a literal, a dropdown list, and a button. <asp:Repeater
This issue occurs in our beloved Internet Explorer 7: I have a list of
I have a String countries[]. now when i click a button then on the
I have a JSF view with a Primefaces data table and a command button
I have a table view, with a long list of strings. There are headers
Following is my code along with the xml file i have 2 table layouts
I have a little functionality to strike out and unstrike out a list view
Hi I have Razor View that Generate a list of Addresses. among all address

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.