2011-04-14 4 views
0

나는 자바와 블랙 베리의 새로운 그리고 난으로 인해 fallowing에 등록 화면이 붙어있어 남성과 여성. 이 '레이블'만이 나를 쓰는 것이 아니며, 웹 서비스에 요청하는 값과 태그입니다.RadiobuttonField 슈퍼, 가치 및 그룹

MyRadioButton rb1=(String label, String value, Group rbg); 

과 슈퍼 (라벨, 가치, 그룹)이다; 내가 뭘 필요로하는 것은 같은 일을했다 --- 더 많은 내부 레이블 ID, 즉 말하자면 pk_id입니다 .---

그래서 내가 선택한 Rbutton을 검색 한 후 값을 가져올 수 있으므로 클릭 할 때 다시 보낼 수 있습니다. 등록 단추.

나는 블랙 베리를 위해 그것을 수행하는 방법의 예를 가지고 있지만 :

Gender[] gender = WebServCall.GetUserGender(); 

    if (gender != null && gender.length == 2) 
    { 

     holder.radiob1.setText(gender[0].genderType); 
     holder.radiob1.setTag(gender[0].PK_ID); 
     holder.radiob2.setText(gender[1].genderType); 
     holder.radiob2.setTag(gender[1].PK_ID); 



    } 
    else 
    { 
     //alert 
    } 
} 

static class ViewHolder 
{ 
    RadioButton radiob1; 
    RadioButton radiob2; 
} 

(...)

// 사용자

에 의해 삽입 된 정보를 가져옵니다. .. RadioButton register_buffer_Gender1 = (라디오 버튼) findViewById (R.id.radiob1); RadioButton register_buffer_Gender2 = (라디오 버튼) findViewById (R.id.radiob2);

... 부울 check1 = register_buffer_Gender1.isChecked(); 부울 check2 = register_buffer_Gender2.isChecked();

는 ....

당신은 블랙 베리에 대한 포기하고이 작업을 수행하는 방법의 예,하지만 수 있을까요?

는 접근 방식이 실제로 블랙 베리 개발에 매우 ​​유사하다 당신에게

답변

1

감사합니다

//Setting up the buttons 
RadioButtonGroup group = new RadioButtonGroup(); 

RadioButtonField radio1 = new RadioButonField(gender[0].genderType, group); 
radio1.setCookie(gender[0].PK_ID); 

RadioButtonField radio2 = new RadioButtoNField(gender[1].genderType, group); 
radio2.setCookie(gender[1].PK_ID); 

add(radio1); 
add(radio2); 

//////////////////////// 

//Retrieving info from the buttons 
boolean check1 = radio1.isSelected(); 
boolean check2 = radio2.isSelected(); 

//or you can use the group 
int checkedIndex = group.getSelectedIndex(); 

내가 RadioButtonFieldRadioButtonGroup에 문서에서 살펴 본다 제안, 당신의 방법에 당신을 얻을 것이다.

+0

나는 그것을 시도 할 것입니다! 대단히 감사합니다 !!! – csbl

+0

IS "MyRadioButton Gender1 = rb1;" 동일한 이름으로 "RadioButton Gender1 = (RadioButton) findViewById (R.id.radiob1);" 그리고 어떻게하면이 "..; 다른 \t 성별 = Gender2.getTag의 toString()(); \t \t 경우 (CHECK1) \t \t \t 성별 = Gender1.getTag의 toString()()"를해야합니까? 이것은 성별 값을 얻는 것입니다. 그래서 등록 할 때 나는 성서에 되돌려 보낼 수 있습니다. 모두 내 첫 번째 게시물을 고려하십시오. – csbl

+0

MyRadioButton은 BB에서 사용하고있는 것입니까? 그렇다면 그렇지만 다른 변수를 할당 할 필요없이 rb1을 사용할 수 있습니다. 두 번째 부분에서는 재 할당하는 경우 rb1 (또는 Gender1)을 사용하고 rb1.getLabel()을 호출하여 RadioButton의 텍스트를 가져올 수 있습니다. 그렇지 않으면 PK_ID를 가져올 수 있습니다. PK_ID가 String 인 경우 rb1.getCookie(). toString()를 호출합니다. – jprofitt