0
레이아웃에서 라디오 버튼을 동적으로 설정해야하지만 가로로 추가하면 라디오 버튼이 한 줄로 표시되어 모든 라디오가 표시됩니다 버튼이 보이지 않으면, 아래 라디오 버튼을 라디오 버튼 위에 놓아야합니다. 라디오 버튼의 왼쪽 옆에있는 텍스트와 함께 가로 방향으로 모든 버튼을 볼 수 있어야합니다. 내 코드는 아래에 있지만 코드는 아래에 있습니다. 단일 행 정도로 모든 라디오 버튼이 표시되지 ..동적으로 라디오 버튼을 레이아웃에 설정해야합니다. android
main.xml에
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose Your Favorite Actress" >
</TextView>
<RadioGroup
android:id="@+id/RadioGroup01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</RadioGroup>
<Button
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit" >
</Button>
</LinearLayout>
및 JA 클래스는 다음과 같습니다 :
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DisplayRadioButton();
}
public void DisplayRadioButton()
{
for(int i=0;i<10;i++)
{
RadioGroup radiogroup = (RadioGroup)findViewById(R.id.RadioGroup01);
RadioButton rdbtn = new RadioButton(this);
rdbtn.setId(i);
rdbtn.setText(text[i]);
radiogroup.addView(rdbtn);
}
}