안드로이드 개발 질문/답변
(글 수 45,052)
package com.test;import android.app.Activity; import android.os.Bundle; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.RadioGroup.OnCheckedChangeListener; public class TestActivity extends Activity implements RadioGroup.OnCheckedChangeListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LinearLayout lr = new LinearLayout(this); RadioGroup rg = new RadioGroup(this); rg.setOnCheckedChangeListener(this); RadioButton radio1 = new RadioButton(this); RadioButton radio2 = new RadioButton(this); lr.addView(rg); } public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub } }
여기서 라디오그룹과 버튼을 xml로 하면 그냥 묶어주면되는데
java만을 이용해서 하려면 어떻게 연결해야될까요?