Code example for Set

Methods: add, clear

0
	public void addCheckedSprite(int position) {
		checkedSprites.add(position);
	} 
 
	public void clearCheckedSprites() { 
		checkedSprites.clear();
	} 
 
	public void setSelectMode(int selectMode) {
		this.selectMode = selectMode;
	} 
 
	public int getSelectMode() { 
		return selectMode;
	} 
 
	public void setShowDetails(boolean showDetails) {
		this.showDetails = showDetails;
	} 
 
	public boolean getShowDetails() { 
		return showDetails;
	} 
 
	@Override 
	public View getView(final int position, View convertView, ViewGroup parent) {
		View spriteView = convertView;
		final ViewHolder holder;
		if (convertView == null) {
			spriteView = inflater.inflate(R.layout.activity_project_spritelist_item, null);
			holder = new ViewHolder();
			holder.background = (RelativeLayout) spriteView.findViewById(R.id.spritelist_item_background);
			holder.checkbox = (CheckBox) spriteView.findViewById(R.id.sprite_checkbox);
			holder.text = (TextView) spriteView.findViewById(R.id.project_activity_sprite_title);
			holder.backgroundHeadline = (LinearLayout) spriteView.findViewById(R.id.spritelist_background_headline);
			holder.objectsHeadline = (LinearLayout) spriteView.findViewById(R.id.spritelist_objects_headline);
			holder.image = (ImageView) spriteView.findViewById(R.id.sprite_img);
			holder.scripts = (TextView) spriteView.findViewById(R.id.textView_number_of_scripts);
			holder.bricks = (TextView) spriteView.findViewById(R.id.textView_number_of_bricks);
			holder.looks = (TextView) spriteView.findViewById(R.id.textView_number_of_looks);
			holder.sounds = (TextView) spriteView.findViewById(R.id.textView_number_of_sounds);
			holder.details = spriteView.findViewById(R.id.project_activity_sprite_details);
			holder.arrow = (ImageView) spriteView.findViewById(R.id.arrow_right);
			spriteView.setTag(holder);
		} else { 
			holder = (ViewHolder) spriteView.getTag();
		} 
 
		holder.checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
 
			@Override 
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if (isChecked) {
					if (selectMode == ListView.CHOICE_MODE_SINGLE) {
						clearCheckedSprites(); 
					} 
					checkedSprites.add(position);
				} else { 
					checkedSprites.remove(position);
				} 
				notifyDataSetChanged();