Code example for CheckedTextView

Methods: getText, isChecked, setCheckMarkDrawable, setChecked

0
 
	Set<String> orderItems = new HashSet<String>();	
	protected void onListItemClick(ListView l, View v, int position, long id) {
		 
		CheckedTextView tt = (CheckedTextView) v;
		String text = tt.getText().toString();
		 
		String item = text;//text.substring(0,text.indexOf("\n"));
		//Toast.makeText(this, text, Toast.LENGTH_LONG).show(); 
		if (!tt.isChecked()) {
			tt.setChecked(true);
			orderItems.add(item);
			tt.setCheckMarkDrawable(android.R.drawable.checkbox_on_background);
		} else { 
			tt.setChecked(false);
			orderItems.remove(item);
			tt.setCheckMarkDrawable(android.R.drawable.checkbox_off_background);
		} 
		 
		//Toast.makeText(this, orderItems.toString()+" position:"+position, Toast.LENGTH_LONG).show();