2016-05-23 25 views
0

單選按鈕焦點出現問題。我也知道有許多與類似主題有關的問題,但是沒有一個涉及單選按鈕(主要是紡織者是有問題的)。Android單選按鈕處於水平方向 - 焦點不起作用

讓我解釋一下:

我:editText1,editText2,有兩個按鈕,更多EDITTEXT盒後水平單選組。

問題出現時,我想填寫所有信息通過鍵入文本並轉到下一個字段。

當我來到單選按鈕1時,我可以通過使用setOnEditorActionListener輕鬆請求焦點。但在此之後,我無法要求關注第二個單選按鈕(右側)。 鍵盤只是跳過,並給了我在收音機組後填寫edittext的可能性。

有不同的建議,但沒有一個符合我的需求。

我曾嘗試: - setOnActionEditor(總是0 actionId) - onKeyListener - 請求重點聯繫方式

因此,要總結:爲什麼水平RadioGroup中不允許單選按鈕來獲得焦點?這很奇怪,我嘗試了很多東西。

對不起,對於長文本,我想要精確。

謝謝!

這裏是XML的一部分:

<EditText 
     android:id="@+id/editTextSurname" 
     android:layout_width="200dp" 
     android:layout_height="40dp" 
     android:inputType="textPersonName" /> 


    <EditText 
     android:id="@+id/editTextName" 
     android:layout_width="200dp" 
     android:layout_height="40dp" 
     android:layout_below="@id/editTextSurname" 
     android:layout_marginTop="5dp" 
     android:inputType="textPersonName" /> 

    <RadioGroup 
     android:id="@+id/gendersRadioGroup" 
     android:layout_width="200dp" 
     android:layout_marginTop="8dp" 
     android:layout_marginBottom="8dp" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/editTextName" 
     android:focusable="true" 
     android:orientation="horizontal" 
     android:focusableInTouchMode="true" 
     android:singleLine="true" 
     android:textSize="12sp"> 

     <RadioButton 
      android:id="@+id/maleRadioButton" 
      android:layout_width="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_height="@dimen/activity_profile_edittext_height" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="@string/male" 
      android:textColor="@drawable/radiobutton_selector" /> 

     <RadioButton 
      android:id="@+id/femaleRadioButton" 
      android:layout_width="wrap_content" 
      android:layout_marginStart="20dp" 
      android:layout_height="@dimen/activity_profile_edittext_height" 
      android:layout_gravity="center_vertical" 
      android:focusable="true" 
      android:focusableInTouchMode="true" 
      android:text="@string/female" 
      android:textColor="@drawable/radiobutton_selector" /> 
    </RadioGroup> 

    <EditText 
     android:id="@+id/dateEditText" 
     android:layout_width="110dp" 
     android:layout_height="40dp" 
     android:layout_below="@+id/gendersRadioGroup" 
     android:inputType="date" /> 
+0

能否請你展示XML,你這個RadioGroup中定義你的佈局?這是必要的,所以我們可以看到爲它指定了哪些屬性值。 – ishmaelMakitla

+0

當然,我已更新問題 – vanste25

+0

嘗試從單選按鈕中刪除'focusable'和'focusableInTouchMode' - 只有'RadioGroup'上有這些。 – ishmaelMakitla

回答

0

您可以使用此代碼的Java文件:

RadioButton radioButton = (RadioButton) findViewById(R.id.maleRadioButton); 
radioButton.setFocusable(true); 
radioButton.setFocusableInTouchMode(true);