public void setMode(InterceptModeItem item) { for (InterceptModeItem i : mItems) { if (item.equals(i)) { item.setIsSelected(true); } else { item.setIsSelected(false); } } }
public void setMode(int index) { for (int i = 0; i < mItems.size(); i++) { InterceptModeItem item = mItems.get(i); if (i == index) { item.setIsSelected(true); } else { item.setIsSelected(false); } } }
/* (non-Javadoc) * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup) */ @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub if (convertView == null) { convertView = initView(); } InterceptModeItem item = (InterceptModeItem) mItems.get(position); TextView mode_title_tv = (TextView) convertView.findViewById(R.id.mode_title_tv); TextView mode_desp_tv = (TextView) convertView.findViewById(R.id.mode_desp_tv); RadioButton radio_button = (RadioButton) convertView.findViewById(R.id.radio_button); mode_title_tv.setText(item.getModeTitle()); mode_desp_tv.setText(item.getModeDesp()); radio_button.setChecked(item.isSelected()); return convertView; }