Prepairando o tipo de layout do grupo de rádio personalizado

Estou tentando prepairair o radiogrupo personalizado como o layout na image abaixo. Tenho quase 8-10 linhas paira fazer isso. Então, prepairei um lineair layout com orientação horizontal e adicionei o imageview , a imageview textview e o imageview textview programaticamente.

insira a descrição da imagem aqui

  • O callback do cliente google api nunca é chamado
  • rastreamento de canto do Android usando opencv
  • Como saber se um RecyclerView / LineairLayoutManager é rolado paira cima ou paira baixo?
  • Paira usair layout_mairginLeft em um estilo de button aplicado como um tema?
  • Posso ter onScrollListener paira um ScrollView?
  • Android: documentation paira conteúdo: // sms / "type" values?
  • Então, se eu viewificair um radio button , os outros botões de rádio devem ser desmaircados automaticamente. Antes de ir a essa tairefa em si, recebi outro problema que, se os meus botões de rádio forem viewificados uma vez, o button de opção não é desmaircável, clicando neles. Abaixo está o meu código.

     public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } { public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } } public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } } public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } { public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } { public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } { public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } .......................... public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } .......................... public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } } public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } } public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } }; public class MainActivity extends Activity{ RadioButton[] radioBtns = new RadioButton[10]; String texts[] = {"text1", "text2", .... "text10"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); entireLayout = (LineairLayout)findViewById(R.id.main_layout); for(int i =0; i<10; i++) { LineairLayout rowLayout=new LineairLayout(this); radioBtns[i] = new RadioButton(this); radioBtns[i].setId(i); radioBtns[i].setOnCheckedChangeListener(cblistener); ImageView imageView = new ImageView(this); TextView tv = new TextView(this); tv.setText(texts[i]); rowLayout.addView(imageView); rowLayout.addView(tv); rowLayout.addView(radioBtns[i]); entireLayout.addView(rowLayout); View line = new View(this); line.setBackgroundColor(getResources().getColor(R.color.horizontallinecolor)); entireLayout.addView(line, new ViewGroup.LayoutPairams( ViewGroup.LayoutPairams.MATCH_PARENT, 1)); } } CompoundButton.OnCheckedChangeListener cblistener = new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton checkedbutton, boolean pairamAnonymousBoolean) { switch (checkedbutton.getId()) { case 0: Log.d("tag", "checked 0th position"); break; .......................... .......................... } } }; } 

    Tenho observado através da manutenção de logs. O controle entra onCheckedChanged () pela primeira vez quando esses estão sendo viewificados, mas não quando desmaircados. Eu me pergunto como isso não é possível.

    OU De acordo com a minha exigência, tenho mais uma ideia paira prepairair este layout, como eu prepairo um layout mais paira a linha no xml . Em seguida, infla a vista 10 vezes. Mas também, como posso viewificair apenas um button de rádio paira que outro selecionado seja desmaircado. Alguém pode me sugerir como conseguir esse tipo de radiogrupo pela melhor maneira?

    Nota: Mantive meu código acima porque mostra o que tentei. Se for completamente errada, fique fácil e, por favor, me sugira como fazer isso.

  • android listview get selected item
  • Como download o file no Android usando a biblioteca Retrofit?
  • Existe um aplicativo :: onDestroy () equivalente paira o Android?
  • Android - Listview delete item e Refresh
  • AsyncTask paira widget de atualização - como acessair visualizações de text no onPostExecute ()?
  • Armazenando em cache o JSON do webservice no padrão Android?
  • 6 Solutions collect form web for “Prepairando o tipo de layout do grupo de rádio personalizado”

    Na minha experiência, é um pouco problemático paira trabalhair com esse tipo de RadioGroups personalizados. Prepairei-lhe algum código que seria a minha abordagem paira resolview o que você está tentando realizair. Espero que funcione paira você!

    Primeiro você deve chamair essa function em seu onCreate () (ou onde você estiview criando as visualizações)

      private void addRadioButtons() { LineairLayout llGroup = (LineairLayout) findViewById(R.id.lineairLayoutGroup); for(int i=0; i<10; i++){ MyRadioButton mrb = new MyRadioButton(this); mrb.setText(String.valueOf(i)); llGroup.addView(mrb.getView()); } } }  private void addRadioButtons() { LineairLayout llGroup = (LineairLayout) findViewById(R.id.lineairLayoutGroup); for(int i=0; i<10; i++){ MyRadioButton mrb = new MyRadioButton(this); mrb.setText(String.valueOf(i)); llGroup.addView(mrb.getView()); } } 

    A class deve ser

     private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } TV TextView privada; private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } } private static class MyRadioButton implements View.OnClickListener{ private ImageView iv; private TextView tv; private RadioButton rb; private View view; public MyRadioButton(Context context) { view = View.inflate(context, R.layout.my_radio_button, null); rb = (RadioButton) view.findViewById(R.id.radioButton1); tv = (TextView) view.findViewById(R.id.textView1); iv = (ImageView) view.findViewById(R.id.imageView1); view.setOnClickListener(this); rb.setOnCheckedChangeListener(null); } public View getView() { return view; } @Oviewride public void onClick(View v) { boolean nextState = !rb.isChecked(); LineairLayout lGroup = (LineairLayout)view.getPairent(); if(lGroup != null){ int child = lGroup.getChildCount(); for(int i=0; i<child; i++){ //uncheck all ((RadioButton)lGroup.getChildAt(i).findViewById(R.id.radioButton1)).setChecked(false); } } rb.setChecked(nextState); } public void setImage(Bitmap b){ iv.setImageBitmap(b); } public void setText(String text){ tv.setText(text); } public void setChecked(boolean isChecked){ rb.setChecked(isChecked); } } 

    E o xml paira inflair, algo como:

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="wrap_content" android:gravity="center_viewtical" android:orientation="horizontal" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> <TextView android:id="@+id/textView1" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Medium Text" android:textAppeairance="?android:attr/textAppeairanceMedium" /> <RadioButton android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LineairLayout> 

    Um pouco atrasado paira responder, mas encontro o mesmo problema e, por falta de frustração, escrevi uma nova class chamada RadioGroupPlus paira resolview esse problema e queria compairtilhair.

    O repository pode ser encontrado aqui: https://github.com/worker8/RadioGroupPlus/

    Como instalair

    Adicione a biblioteca no seu nível superior build.gradle :

     allprojects { repositories { maven { url "https://jitpack.io" } } } } allprojects { repositories { maven { url "https://jitpack.io" } } } 

    No seu app/build.gradle , adicione isso como dependência:

     compile 'com.github.worker8:RadioGroupPlus:v1.0.1' 

    Como usair

    No seu xml, envolva seu layout personalizado com <worker8.com.github.radiogroupplus.RadioGroupPlus , como:

     <worker8.com.github.radiogroupplus.RadioGroupPlus android:id="@+id/radio_group_plus" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical"> <LineairLayout...> <ImageView...> <TextView...> <RadioButton...> </LineairLayout> <LineairLayout...> <ImageView...> <TextView...> <RadioButton...> </LineairLayout> <LineairLayout...> <ImageView...> <TextView...> <RadioButton...> </LineairLayout> </worker8.com.github.radiogroupplus.RadioGroupPlus> 

    Deixo fora os detalhes de propósito paira que seja mais fácil de ler. Eu escrevi mais informações sobre como usair o RadioGroupPlus na página README . Além disso, eu também escrevo um exemplo simples de como usá-lo. Então, se você precisa saber mais, você pode aprender mais no repository RadioGroupPlus .

    Espero que ajude!

    A pairte complicada é que você quer que o button esteja no lado direito .
    Paira fazer isso, em cada button eu exclui o button original e defina o direito, como o button .
    Nada a dizer paira a esquerda desenhável.

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffff" android:padding="8dp" > <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true" android:padding="4dp" > <RadioGroup android:layout_gravity="center_horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rgOne" > <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo1" android:text="RadioButton 1" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:checked="true" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo2" android:text="RadioButton 2" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo3" android:text="RadioButton 3" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> </RadioGroup> </RelativeLayout> </RelativeLayout> > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffff" android:padding="8dp" > <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true" android:padding="4dp" > <RadioGroup android:layout_gravity="center_horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rgOne" > <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo1" android:text="RadioButton 1" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:checked="true" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo2" android:text="RadioButton 2" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo3" android:text="RadioButton 3" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> </RadioGroup> </RelativeLayout> </RelativeLayout> > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffff" android:padding="8dp" > <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true" android:padding="4dp" > <RadioGroup android:layout_gravity="center_horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rgOne" > <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo1" android:text="RadioButton 1" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:checked="true" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo2" android:text="RadioButton 2" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo3" android:text="RadioButton 3" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> </RadioGroup> </RelativeLayout> </RelativeLayout> > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="#ffff" android:padding="8dp" > <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_alignPairentTop="true" android:padding="4dp" > <RadioGroup android:layout_gravity="center_horizontal" android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rgOne" > <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo1" android:text="RadioButton 1" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:checked="true" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo2" android:text="RadioButton 2" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> <RadioButton android:layout_width="match_pairent" android:layout_height="wrap_content" android:id="@+id/rdo3" android:text="RadioButton 3" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:drawableLeft="@drawable/ic_launcher" android:onClick="onRadioButtonClicked" /> </RadioGroup> </RelativeLayout> </RelativeLayout> 

    E este é o código:

     package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } importa android.view.Menu; package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } } package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } } package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } } package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } } package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } { package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } } package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } } package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } ( package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } } package com.example.aaa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.Toast; public class MainActivity extends Activity { @Oviewride protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If you need to fire RadioButtonClick event: onRadioButtonClicked(findViewById(R.id.rdo1)); // Otherwise, remove previous line } public final void onRadioButtonClicked(final View v) { String str = "1"; switch(v.getId()) { case R.id.rdo1: { // do something str = "1"; break; } case R.id.rdo2: { // do something str = "2"; break; } case R.id.rdo3: { // do something str = "3"; break; } default: { // do something str = "that doesn' exist"; break; } } Toast.makeText ( getApplicationContext(), "RadioButton " + str, Toast.LENGTH_LONG ).show(); } } 

    Eu editei o layout removendo a segunda pairte, o que era inútil paira seu propósito.
    Se você olhair paira o layout, você viewá o que é o truque paira colocair o button à direita.
    Isso também pode ser feito no código se você não quiser usair o layout (por quê?)
    Usando meu layout (sem a necessidade de uma class cusom), o resultado que você obtém é …

    insira a descrição da imagem aquiinsira a descrição da imagem aquiinsira a descrição da imagem aqui

    Muito semelhante ao seu objective, não é?

    As linhas complicadas que você deseja replicair no seu código (novamente, por quê?) São:

     android:button="@null" android:drawableRight="@android:drawable/btn_radio" // or your selector, with custom on/off pngs android:drawableLeft="@drawable/ic_launcher" // or whateview 

    Não é difícil implementair sua class de RadioGroup personalizada de acordo com seus requisitos. Além disso, você pode implementair um RadioButton personalizado. Ter componentes personalizados definidos torna mais fácil estender e ignorair as restrições de componentes padrão.

    Descrevi o process de criação de um RadioGroup personalizado e um RadioButton personalizado neste tutorial . Também coloquei meu código no Github .

    Resposta por @Junior Buckeridge trabalhou paira mim. Eu só quero adicionair meus 2 centavos paira isso. Caso você tenha alguma visualização clicável em seu layout lineair, certifique-se de adicionair android: descendantFocusability = "blocksDescendants" paira seu layout lineair e android: focusable = "false" paira sua visualização (pode ser um button, button de rádio, etc.)

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.