안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요..
라디오버튼을 동적테이블에서사용시
질문입니다..
먼저아래는 1~15까지 For루프를 돌려서 나온 결과 이구요..
라디오 버튼을 눌러도 그룹이 안되어 있어서 아래와같이 나오는데요..
질문사항은
1. 먼저 라디오버튼을 하나 체크하면 다른것들은 체크가 안되게 하고 싶습니다.
2. 예를들어 저기서 "Number=3" 의 라디오버튼을 클릭하면 토스트 메세지로 "Clicked Number is 3" 이 출력되게 하고 싶습니다.
소스 수정좀 부탁드려욤~~ 꼭좀 부탁드립니다.
한..4~5일정도 뒤졌는데 동적테이블에 대한 라디오 버튼 그룹하는것이 나와있지 않네요..
부탁드립니다^^

레이아웃xml은 다음과 같구요..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TableLayout>
</ScrollView>
</LinearLayout>
액티비티소스는 아래와 같습니다.
package pe.test.android;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class TestActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
TableLayout nubmerTable = (TableLayout)findViewById(R.id.tableLayout1);
for(int i=0; i<15; i++)
{
TableRow newRow = new TableRow(this);
TextView number = new TextView(this);
number.setWidth(200);
number.setText("Number="+i);
newRow.addView(number);
RadioButton rb = new RadioButton(this);
rb.setId(i);
newRow.addView(rb);
nubmerTable.addView(newRow);
}
}
}