Control is implemented inside the adapter GetView.
private int selectposition =-1;class payadapter extends baseadapter{@Overridepublic int GetCount () {//TODO auto-generate D method Stubreturn paylist==null?0:paylist.size ();} @Overridepublic Object getItem (int position) {//TODO auto-generated method Stubreturn paylist.get (position);} @Overridepublic long Getitemid (int position) {//TODO auto-generated method Stubreturn position;} @Overridepublic View GetView (final int position, view Convertview, ViewGroup parent) {Viewholder holder = null;if (CONVERTV Iew = = null) {Convertview = Layoutinflater.from (context). Inflate (r.layout.pay_listview_item_layout,null); holder = new Viewholder (); holder.image = (ImageView) Convertview.findviewbyid (r.id.pay_bank_icon_imageview); holder.title = ( TextView) Convertview.findviewbyid (r.id.pay_bank_title_textview); holder.description = (TextView) Convertview.findviewbyid (r.id.pay_bank_description_textview); Holder.radio = (RadioButton) Convertview.findviewbyid (R.ID.PAY_SELECT_RADIOBTN); Convertview.settag (holder);} Else{holder = (Viewholder) Convertview.gettag ();} Pay pay = (pay) GetItem (position), Holder.image.setImageResource (Getresources (). Getidentifier (Pay.getimage (), " Drawable ", Context.getpackagename ())); Holder.title.setText (Pay.gettitle ()); Holder.description.setText ( Pay.getdescription ()); Holder.radio.setOnCheckedChangeListener (new Oncheckedchangelistener () {@Overridepublic void OnCheckedChanged (Compoundbutton Buttonview, Boolean isChecked) {if (isChecked) {selectposition = position;} Notifydatasetchanged ();}}); if (selectposition==position) {holder.radio.setChecked (true);} Else{holder.radio.setchecked (false);} if (position==0) {holder.radio.setChecked (true);} return Convertview;}} Class Viewholder{imageview image; TextView title; TextView description; RadioButton Radio;}
Android ListView Radio Feature