1. layout.xml
<!-- 회원 구분 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:orientation="horizontal">
<RadioGroup
android:id="@+id/memGrp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/memtype1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dp"
android:layout_marginLeft="14dp"
android:text="@string/label_jointype_app" />
<RadioButton
android:id="@+id/memtype2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:paddingLeft="2dp"
android:layout_marginLeft="14dp"
android:text="@string/label_jointype_mem" />
</RadioGroup>
</LinearLayout>
2. JAVA code
private RadioGroup memGrp;
this.memGrp = (RadioGroup)v.findViewById(R.id.memGrp);
String userid = useridView.getText().toString().trim();
if(memGrp.getCheckedRadioButtonId() == R.id.memtype1){
userid=Const.APP_MEMBER_KWD+userid;
Log.e(TAG,"user id : "+userid);
return parser.requestAppUserLogin(userid, userpwdView.getText().toString().trim());
} else {
return parser.requestUserLogin(userid, userpwdView.getText().toString().trim());
}
3. 초기값 선택
you should check the radiobutton in the radiogroup like this:radiogroup.check(IdOfYourButton)
ex) this.memGrp.check(R.id.memtype1);
댓글 없음:
댓글 쓰기