라디오 버튼 줄 바꿈 - ladio beoteun jul bakkum

티스토리 뷰

APK 16 이하
<RadioButton
    android:id="@id/radio"
    android:text="text"
    android:paddingLeft="5dp" />

APK 17 이상
<RadioButton
    android:id="@id/radio"
    android:text="text"
    android:paddingStart="5dp" />
or
<RadioButton
    android:id="@id/radio"
    android:text="text"
    android:paddingLeft="5dp" />

APK 16 이하
android:paddingLeft="?dp" 를 추가 하시면 됩니다.

APK 17 이상
android:paddingStart="?dp"
or
android:paddingLeft="?dp"
를 추가 하시면 됩니다.

문제 설명

줄 바꿈으로 R 반짝이 앱의 라디오 버튼 분리 (Separating radioButtons in R shiny app with a line break)

제 반짝이는 앱에 radioButtons 목록이 있는데 헤더, 줄이나 단락 나누기와 같은 공백 또는 줄 ‑‑‑‑‑‑‑‑ . 버튼의 세 가지 개별 formType(formType1, formType2, formType3)을 만들어 이를 수행하려고 했지만 버튼의 기능이 작동을 멈췄습니다. 나는 많은 HTML 코드를 모르지만 내가 시도한 것들은 radioButton 코드 청크에서 작동하지 않을 것입니다. 도울 수 있니? 감사. 아래에 **BREAK HERE**

로 라디오 버튼을 구분할 위치를 지정했습니다.
# Create Navigation Bar
   navbarPage("Navigation Bar",
     # Create a tab for data Entry
     tabPanel(
       "Data Entry",
       sidebarLayout(
         sidebarPanel(
           radioButtons(
             "formType", "Form Type",
             c("Basic Info & Universal Flagging" = "basic_info",
               "Universal Screening" = "uni_screening",

               `**BREAK HERE**`

               "BHAP Screening" = "bhap_screening",
               "BHAP Intake & Assessment" = "bhap_intakeassessment",
               "BHAP Referral" = "bhap_referral", "BHAP Contact Info" = "bhap_contactinfo",
               "BHAP Case Management" = "bhap_casemanagement", "BHAP Exit" = "bhap_exit", 

               `**BREAK HERE**`

               "COAP Intake" = "coap_intake", "COAP Assessment" = "coap_assessment", 
               "Intercept 3: COAP In‑Jail Servces" = "coap_injailservices",
               "Intercept 4: COAP Support Services Needs" = "coap_supportservices",
               "Intercept 4: COAP Reentry/Community‑Based Referrals" = "coap_reentrycommunity",
               "Provider Updates (In‑Jail and Community‑Based)" = "coap_providerupdates",
               "COAP Contact Info" = "coap_contactinfo", "COAP Case Management" = "coap_casemanagement",
               "COAP EXIT" = "coap_exit"))
           ),

         # outputs the dynamic UI component
          uiOutput("ui")
         )
       ),

참조 솔루션

방법 1:

Try inserting hr(), which is a horizontal rule. This should put in a space with a horizontal line. Another option would be br(), a blank rule, doing the same minus the line.

방법 2:

You can add javascript/jQuery to specify breaks after specific radio buttons, adding <hr> when indicated:

ui <‑ fluidPage(
  # Create Navigation Bar
  navbarPage("Navigation Bar",
    # Create a tab for data Entry
    tabPanel(
     "Data Entry",
     sidebarLayout(
       sidebarPanel(
         radioButtons(
           "formType", "Form Type",
           c("Basic Info & Universal Flagging" = "basic_info",
             "Universal Screening" = "uni_screening",
             "BHAP Screening" = "bhap_screening",
             "BHAP Intake & Assessment" = "bhap_intakeassessment",
             "BHAP Referral" = "bhap_referral", "BHAP Contact Info" = "bhap_contactinfo",
             "BHAP Case Management" = "bhap_casemanagement", "BHAP Exit" = "bhap_exit", 
             "COAP Intake" = "coap_intake", "COAP Assessment" = "coap_assessment", 
             "Intercept 3: COAP In‑Jail Servces" = "coap_injailservices",
             "Intercept 4: COAP Support Services Needs" = "coap_supportservices",
             "Intercept 4: COAP Reentry/Community‑Based Referrals" = "coap_reentrycommunity",
             "Provider Updates (In‑Jail and Community‑Based)" = "coap_providerupdates",
             "COAP Contact Info" = "coap_contactinfo", "COAP Case Management" = "coap_casemanagement",
             "COAP EXIT" = "coap_exit")),
         tags$head(tags$script(HTML("
             $(document).ready(function(e) {
                $('input[value=\"uni_screening\"]').parent().parent().after('<hr>');
                $('input[value=\"bhap_exit\"]').parent().parent().after('<hr>');
             })
             ")))
       ),
       # outputs the dynamic UI component
       uiOutput("ui")
     )
    )
  )
)

(by Jason、TTS、Ben)

참조 문서

  1. Separating radioButtons in R shiny app with a line break (CC BY‑SA 2.5/3.0/4.0)

라디오 버튼을 이용하여 DIV를 각각 활성화 시켜서 사용하는 함수를 간단히 작성하면 아래와 같다.

- HTML

<input type="radio" name="tp_cd" value="1" checked="checked"> 1번

<input type="radio" name="tp_cd" value="2" > 2번

<div id="POP1"><p>POP1의 영역이 보임</p></div>

<div id="POP2" style="display:none;"><p>POP2의 영역이 보임</p></div>

- jquery

$('input[type=radio][name=tp_cd]').on('click', function() {

var chkValue = $('input[type=radio][name=tp_cd]:checked').val();

if (chkValue == '1') {

$('#POP1').css('display', 'block');

$('#POP2').css('display', 'none');

return false;

} else if (chkValue == '2') {

$('#POP1').css('display', 'none');

$('#POP2').css('display', 'block');

return false;

}

});

위와 같은 방법으로 작성하면 된다.

jquery는 css에 display: none; 일 경우 화면에서 보여지지 않고, display: block; 일 경우 화면에 보여지는 것을 이용한 것이다.

POP2의 영역이 처음부터 노출되는 것을 막기 위해서는 HTML에서 스타일을 주면 된다.

함수 안에 return false;를 입력하게 되면 2번을 선택하더라도 기존에 체크되어있던 라디오버튼 1번에 계속 체크가 되어있다. (DIV는 POP2가 보이게된다.)

이를 해결하기 위해서는 간단하게 return false; 를 지우면 된다.