• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android: Several Radio button in custom list view


Oct 11, 2014
please check code

Problem : when click radio button Question one All questions are clicked on

package com.radiobutton.listview; import java.util.ArrayList; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; public class Adaptersoal extends ArrayAdapter<Structsoal>{ public Adaptersoal(ArrayList<Structsoal> array) { super(G.context, R.layout.adapter_soal,array); } public static class ViewHolder { public TextView txt_soal; public ViewGroup btn_soal; public RadioButton gozine1; public RadioButton gozine2; public RadioButton gozine3; public RadioButton gozine4; public RadioGroup rdb_go; public ViewHolder (View view) { txt_soal = (TextView) view.findViewById (R.id.txt_soal); txt_soal.setTypeface(G.tf); txt_soal.setTextSize(18); gozine1 = (RadioButton) view.findViewById(R.id.gozine1); gozine2 = (RadioButton) view.findViewById(R.id.gozine2); gozine3 = (RadioButton) view.findViewById(R.id.gozine3); gozine4 = (RadioButton) view.findViewById(R.id.gozine4); rdb_go = (RadioGroup) view.findViewById(R.id.rdb_g); btn_soal = (ViewGroup) view.findViewById(R.id.btn_soal); } public void fill(ArrayAdapter<Structsoal> adapter, final Structsoal itemsoal,int position) { txt_soal.setText(itemsoal.s_soal); gozine1.setText(itemsoal.s_gozine1); gozine2.setText(itemsoal.s_gozine2); gozine3.setText(itemsoal.s_gozine3); gozine4.setText(itemsoal.s_gozine4); } } @Override public View getView(int position, View convertViewsoal, ViewGroup parent) { ViewHolder holder; Structsoal itemsoal = getItem(position); if(convertViewsoal==null) { convertViewsoal = G.inflater.inflate(R.layout.adapter_soal,parent,false); holder = new ViewHolder(convertViewsoal); convertViewsoal.setTag(holder); }else { holder = (ViewHolder) convertViewsoal.getTag(); } holder.fill(this, itemsoal, position); return convertViewsoal; } }


We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.