Back to project page book.
The source code is released under:
MIT License
If you think the Android project book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package book; // w w w . j av a 2s .c om import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Set; import com.example.book.R; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.TextView; /* * * used to be selectableListAdapter * but has evolved into list adapter where checkboxes are used to check items * selected or not selected */ public class SelectableWordListAdapter extends ArrayAdapter<String>{ private List<String> words; private final Context context; public SelectableWordListAdapter(Context context) { super(context, R.layout.booklistitem); this.context = context; this.words = new ArrayList<String>(); } public void set(HashMap<String, List<String>> book){ for (String word : book.keySet()){ words.add(word); this.add(word); } } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.selectablewordlistitem, parent, false); // get listitem xml CheckBox item = (CheckBox) rowView.findViewById(R.id.select); // find checkbox item.setText(this.words.get(position)); // put shit in the textfield rowView.setTag(this.words.get(position)); // put shit in the (check)box return rowView; } }