마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

RadioGroup 질문입니다.ㅠㅠ

0 추천

안녕하세요.

 

RadioGroup 그룹으로 데이터를 받아서 Radio button 에 text  를 붙여주었습니다.

하지만 핸드폰마다 글씨가 떨어져서 나오는가 하면 어떤건 딱 달라 붙어서 나오게 되는데요.

혹시 동적으로 라디오 버튼 과 텍스트뷰를  만들어서 RelativeLayout  android:layout_toRightOf 효과를 주어서 라디오 버튼위치 옆에 텍스트뷰를  위치 시킬수 있는 방법이 있을까요? ㅠㅠ

계속 시도는 해보고 있는데 잘안되네요 ㅠㅠㅠ

고수님 조언좀 부탁드립니다.

 

 

public class MainActivity extends Activity
{
private RadioGroup radioGroup = null;
private LinearLayout texts = null;
 
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
 
radioGroup = (RadioGroup) findViewById(R.id.module_radio);
texts = (LinearLayout)findViewById(R.id.dddd);
ArrayList<String> comboBoxInfo = new ArrayList<String>();
comboBoxInfo.add("사과");
comboBoxInfo.add("배");
comboBoxInfo.add("감");
comboBoxInfo.add("귤");
for (int i = 0; i < comboBoxInfo.size(); i++) {
 
LayoutParams layout = new LayoutParams(   LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
 
RadioButton radio = new RadioButton(this);
        radio.setLayoutParams(layout);
       
        TextView text = new TextView(this);
        text.setText(comboBoxInfo.get(i));
        text.setTextColor(Color.BLACK);
       
 
radioGroup.addView(radio);
radioGroup.addView(text);
 
 
      }
   }
}
 
 
 
지금은 결과값
------------------------------------------- 
라디오버튼
사과
라디오버튼
라디오버튼
라디오버튼
-------------------------------------------
 
원하는결과 값
--------------------------------------------
라디오버튼       사과
라디오버튼       배
라디오버튼       감
라디오버튼       귤 
--------------------------------------------
 
도움요청좀 드립니다 ㅠㅠ
스릉스릉 (1,260 포인트) 님이 2013년 8월 6일 질문
스릉스릉님이 2013년 8월 6일 수정

1개의 답변

0 추천
RadioGroup은 기본적으로 vertical한 orientation을 가지고 있습니다.

RadioGroup에 android:orientation="horizontal" 을 넣으면 가로로 정렬될 것입니다.

Radio버튼 우측에 text가 왜 필요한지 모르겠으나 RadioButton에 text를 추가하여 쓰는것이 낫지 않을까요?
익명사용자 님이 2013년 8월 6일 답변
...