how to display a edittext when radiobutton is clicked in android -
i have program computes perimeter, circumference, area of different shapes like, square, circle, rectangle , soon. enabling radiobutton display edittext write measurements.
check below code don't use is, reference
inyourxml.xml
<radiogroup android:id="@+id/groupradio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="@dimen/app_big_margin" android:layout_marginright="@dimen/app_normal_margin" android:gravity="center" android:minheight="30dp" android:orientation="horizontal" > <radiobutton android:id="@+id/circumferenceradio" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/tab_selector_background" android:button="@null" android:checked="true" android:gravity="center" android:text="@string/choice_yes" android:textcolor="@drawable/tab_selector_text" /> <radiobutton android:id="@+id/perimeterradio" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/tab_selector_background" android:button="@null" android:checked="false" android:gravity="center" android:text="@string/choice_no" android:textcolor="@drawable/tab_selector_text" /> </radiogroup> <edittext android:id="@+id/perimeteredittext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="@dimen/app_normal_margin" android:layout_marginright="@dimen/app_normal_margin" android:background="@drawable/action_bar_background" android:inputtype="textpassword" /> <edittext android:id="@+id/circumferenceedittext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="@dimen/app_normal_margin" android:layout_marginright="@dimen/app_normal_margin" android:background="@drawable/action_bar_background" android:inputtype="textemailaddress" />
inyourjava.java
radiogroup groupradio=(radiogroup)rootview.findviewbyid(r.id.groupradio); edittext perimeteredittext=(edittext)rootview.findviewbyid(r.id.perimeteredittext); edittext circumferenceedittext=(edittext)rootview.findviewbyid(r.id.circumferenceedittext); groupradio.setoncheckedchangelistener(new oncheckedchangelistener() { @override public void oncheckedchanged(radiogroup group, int checkedid) { if(checkedid==r.id.circumferenceradio) { circumferenceedittext.setvisibility(view.visible); perimeteredittext.setvisibility(view.invisible); } else if(checkedid==r.id.perimeterradio) { perimeteredittext.setvisibility(view.visible); circumferenceedittext.setvisibility(view.invisible); } } });
Comments
Post a Comment