Code example for SparseBooleanArray

Methods: keyAtsizevalueAt

0
	protected void setInvitees() 
	{ 
		final ListView v = getListView();
		final SparseBooleanArray checkstates = v.getCheckedItemPositions();
		final ArrayList<Long> invited_friends = new ArrayList<Long>();
		for (int i = 0; i < checkstates.size(); i++) {
			if (checkstates.valueAt(i) == true) {
				final long id = v.getAdapter().getItemId(checkstates.keyAt(i));
				invited_friends.add(id);
			} 
		} 
		final Intent i = new Intent();
		i.putExtra("invited", invited_friends);
		setResult(RESULT_OK, i);
	} 
 
	@Override 
	protected void onPause() 
	{ 
		super.onPause();