I want to put two buttons in listView.
public class Imenik extends ListActivity {
@Override
public long getSelectedItemId() {
// TODO Auto-generated method stub
return super.getSelectedItemId();
}
@Override
public int getSelectedItemPosition() {
// TODO Auto-generated method stub
return super.getSelectedItemPosition();
}
ListView lv;
Cursor Cursor1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//create a cursor to query the Contacts on the device to start populating a listview
Cursor1 = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
null,
null,
null);
startManagingCursor(Cursor1);
String[] from = {
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone._ID}; // get the list items for the listadapter could be TITLE or URI
int[] to = {android.R.id.text1,
android.R.id.text2}; //sets the items from above string to listview
//new listadapter, created to use android checked template
SimpleCursorAdapter listadapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, Cursor1, from, to );
setListAdapter(listadapter);
//adds listview so I can get data from it
lv = getListView();
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
}
with this code I get all contacts names and numbers and put in the list, but I want two buttons and in every row checkBox, and user can click on item – mark checkBox and click confirm button to get those values in an array.
Help, thank you, Wolf.
And again…
Build a custom Adapter that uses your data…
Example
http://android.vexedlogic.com/2011/04/02/android-lists-listactivity-and-listview-ii-%E2%80%93-custom-adapter-and-list-item-view/