Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>But i figured it out myself. I only wanted to select the row by clicking on the checkBox view.</p> <p>I modified my custom Array Adapter</p> <p>Here is my code:</p> <pre><code>public class ContactAdapter extends ArrayAdapter&lt;Contact&gt; implements OnClickListener{ private static HashMap&lt;Integer, Boolean&gt; teamItems = new HashMap&lt;Integer, Boolean&gt;(); int count = 0; private List&lt;Contact&gt; items; private int mode; CheckBox add_to_team; static int counter = 3; public ContactAdapter(Context context, int textViewResourceId, List&lt;Contact&gt; objects, int mode) { super(context, textViewResourceId, objects); // TODO Auto-generated constructor stub this.context = context; this.mode = mode; this.items = objects; } @Override public View getView(int position, View convertView, final ViewGroup parent) { View v = convertView; if(v == null) { //get a reference to the LayoutInflator LayoutInflater li = (LayoutInflater)getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); //and inflate our XML into the View v = li.inflate(R.layout.list_contacts_item, null); } String race = items.get(position).race; String nick = items.get(position).nick; String name = items.get(position).name; final int pos = position; if(v!= null) { // Do the work for the other views // MODE 1 = SELECTION-MODE if(mode == 1) { add_to_team.setVisibility(0); try { if(count!=0) { boolean b = teamItems.get(pos); if(b==false) { add_to_team.setChecked(false); } else { add_to_team.setChecked(true); } } } catch (NullPointerException e) { } add_to_team.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { teamItems.put(pos, arg1); count++; } }); } else { add_to_team.setVisibility(8); } } return v; } </code></pre> <p>}</p> <p>I added a HashMap in which I save the selected items. I can call the select state from my activity, by calling the HashMap... And it works great!</p>
    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.
    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