Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the selected contacts from Check box (Android)
    primarykey
    data
    text
    <p>I am creating a group android SMS. Therefore, i need checkbox. But,my problem is i cant figure out how to get the selected contacts?</p> <p>This my layout:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/topLayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true"&gt; &lt;ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:choiceMode="multipleChoice"&gt; &lt;/ListView&gt; &lt;ImageView android:id="@+id/contact_image" android:src="@drawable/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Name: " android:id="@+id/contact_name" android:textSize="18dip" android:layout_below="@id/contact_image" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Phone: " android:id="@+id/phone_number" android:textSize="28dip" android:layout_below="@id/contact_name" /&gt; &lt;CheckBox android:id="@+id/checkBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:layout_alignParentRight="true" android:focusable="false"&gt; &lt;/CheckBox&gt; &lt;/RelativeLayout&gt; </code></pre> <p>This my codes:-</p> <pre><code> package com.droidnova.android.samples; import android.app.ListActivity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.provider.Contacts.People; import android.util.SparseBooleanArray; import android.view.Menu; import android.view.MenuItem; import android.view.MenuInflater; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.ListView; import android.widget.SimpleCursorAdapter; public class Contacts extends ListActivity { private CheckBox checkBox; private ListView listView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listView=(ListView)findViewById (R.id.list); final ListView listView = getListView(); listView.setItemsCanFocus(false); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_multiple_choice, lv_items)); Cursor cursor = getContentResolver().query(People.CONTENT_URI, new String[]{People._ID,People.NAME,People.NUMBER}, null, null, null); startManagingCursor(cursor); // start mappings String[] columns = new String[] {People.NAME, People.NUMBER}; int[] names = new int[] {R.id.contact_name, R.id.phone_number}; SimpleCursorAdapter myAdapter = new SimpleCursorAdapter(this, R.layout.contact, cursor, columns, names); setListAdapter(myAdapter); this.setListAdapter(myAdapter); } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.firstmenu,menu); return true; } public boolean onOptionsItemSelected(MenuItem item){ switch(item.getItemId()){ case R.id.next: next(); break; case R.id.select: return true; case R.id.back: final Intent i = new Intent(this,SelectContact.class); startActivity(i); break; } return false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload