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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:52:29+00:00 2026-06-14T06:52:29+00:00

here is my code, when i click button b a listview populates with a

  • 0

here is my code, when i click button “b” a listview populates with a checkbox for each item, now i want to get items with check box checked into another activity, how do i acheive this, i came half way i’m confused how to do the remaining part

here is my code
XML file :

<Button
    android:id="@+id/b"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Pick contact" />

<ListView
    android:choiceMode="multipleChoice"
    android:id="@+id/lv"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

This is java code:

import java.util.ArrayList;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
 import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity {
Button b;
int PICK_CONTACT;
ArrayList<String> al;
ArrayAdapter<String> aa;
ListView lv;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    b = (Button) findViewById(R.id.b);

    lv = (ListView) findViewById(R.id.lv);
    al = new ArrayList<String>();



    b.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            displaycontacts();
            System.out.println("size" + al.size());
            aa = new ArrayAdapter<String>(MainActivity.this,
                        android.R.layout.simple_list_item_multiple_choice, al);
            lv.setAdapter(aa);


        }
    });

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position ,long arg3) 
        {

            //here i should get the item which is checked
        }
    });

}

public void displaycontacts() {
    try {
        ContentResolver cr = getContentResolver();
        Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
                null, null, null);

        if (cur.getCount() > 0) {
            while (cur.moveToNext()) {

                String name = cur
                        .getString(cur
                                .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                if (Integer
                        .parseInt(cur.getString(cur
                                .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
                    System.out.println("name : " + name);
                    al.add(name);

                }
            }

        }

    } catch (Exception e) {
        System.out.println("Error:::::::::::::::::::" + e);
    }

}
}
  • 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-14T06:52:30+00:00Added an answer on June 14, 2026 at 6:52 am

    try this link for list view with multiple choice. http://android-coding.blogspot.in/2011/09/listview-with-multiple-choice.html.
    Let me know your problem is resolved or not?

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

Sidebar

Related Questions

Here in this code: $('#doneItem').click(function(){ $(this).each(function(index){ var item = 'personal' + index; alert(item); localStorage.removeItem('personal'
Here is the code for the button click event; Protected Sub CompetenciesButton_Click(ByVal sender As
Is this possible? Code: $('#goRightBtn').click(function() { Random code here }; I have a button,
in my app when i click a button showing a dialog box with listview.
Here is my code: $('.button').click(function() { $(this).addClass('clicked'); $('.button').not(this).removeClass('clicked') .addClass('not_clicked'); $('#tool_window,#wrapper').not('#work_area').not('.button').addClass('outside'); }); $('.outside').click(function() { $('.clicked').removeClass('clicked');
here is the code, currently the progressdialog is shown if user click the button,
I have a ListView , and when I click a button, I want to
i have listview with checkboxes and save button. Whichever checkboxes i check and click
here is the code: http://jsfiddle.net/4WyPq/ So basically when I click 'button1' it animates then
Here is my code: $(#myCheckBox).click(function () { if (!$(this).is(':checked')) { $('#txtDateFrom').attr('readonly', true); $('#txtDateTo').attr('readonly', true);

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.