2016-11-05 114 views
0

我已经创建了3个单选按钮。有2个edittext字段和一个下拉菜单。会显示提示,但也可以编辑文本和下拉菜单。默认情况下,应显示第一个按钮的提示。现在下拉列表位于两个文本字段之间。在选择第二个按钮时,我希望提示更改,下拉应该位于两个edittext之上。我怎么做?如何更改提示选择不同的单选按钮?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#e5e5e5"> 


<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_weight="0.90" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 

    <RadioButton android:id="@+id/radio_recharge" 
     android:layout_width="wrap_content" 
     android:text="Mobile" 
     android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" 
     android:layout_weight="0.33" 
     android:layout_height="wrap_content" 
     android:onClick="onRadioButtonClicked"/> 

    <RadioButton android:id="@+id/radio_bills" 
     android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" 
     android:layout_width="wrap_content" 
     android:text="DTH" 
     android:layout_weight="0.33" 
     android:layout_height="wrap_content" 
     android:onClick="onRadioButtonClicked"/> 

    <RadioButton android:id="@+id/radio_transfer" 
     android:layout_width="wrap_content" 
     android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" 
     android:text="DataCard" 
     android:layout_weight="0.33" 
     android:layout_height="wrap_content" 
     android:onClick="onRadioButtonClicked"/> 


</RadioGroup> 

<LinearLayout 
    android:orientation="vertical" 
    android:layout_weight="0.10" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textPersonName" 
     android:layout_marginTop="5dp" 
     android:text="Mobile Number" 
     android:ems="10" 
     android:id="@+id/editText2" /> 

    <Spinner 
     android:id="@+id/spinner1" 
     android:layout_width="match_parent" 
     android:layout_marginTop="10dp" 
     android:layout_height="wrap_content" 
     android:background="@android:drawable/btn_dropdown" 
     android:spinnerMode="dropdown" /> 



    <EditText 
     android:layout_width="match_parent" 
     android:layout_marginTop="10dp" 
     android:layout_height="wrap_content" 
     android:inputType="textPersonName" 
     android:text="Recharge Amount" 
     android:ems="10" 
     android:id="@+id/editText" /> 
</LinearLayout> 

回答

1

要设置提示,编辑文本,您可以使用setHint( “提示文本”)方法。

您可以在微调器和底部编辑文本之间再添加一个编辑文本,并将可见性设置为消失。 打开第二个单选按钮,使可视性最上方的编辑文本消失,并使微调器和底部编辑文本之间的编辑文本可见