java - Disabling textfields on button click and simultaniously enabling another button -
this question has answer here:
- how disable android button? 9 answers
i have:
my textfields textinput
& textinput2
, btnclickme
disabled & button2
enabled when click on button bevestig weddenschap
.
i cannot figure out how this. can me out?
xml code:
<textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/details_frankrijk" android:textsize="17sp" android:id="@+id/tvdetails" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="@string/positie" android:id="@+id/lbloutput" android:layout_below="@+id/tvdetails" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_margintop="28dp" android:layout_alignparentright="true" android:layout_alignparentend="true" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txtinput" android:layout_below="@+id/lbloutput" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignright="@+id/lbloutput" android:layout_alignend="@+id/lbloutput" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="@string/bedrag" android:id="@+id/lbloutput2" android:layout_below="@+id/txtinput" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignparentright="true" android:layout_alignparentend="true" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/txtinput2" android:layout_below="@+id/lbloutput2" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignright="@+id/lbloutput2" android:layout_alignend="@+id/lbloutput2" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/bevestig_weddenschap" android:id="@+id/button" android:layout_below="@+id/plaatsbet" android:layout_torightof="@+id/tvdetails" android:layout_toendof="@+id/tvdetails" android:onclick="btnclickme" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="@string/plaats_de_weddenschap" android:id="@+id/plaatsbet" android:layout_below="@+id/txtinput2" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/volgende" android:id="@+id/button2" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:layout_alignparentend="true" android:clickable="false" />
java code:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_tweedescherm); textview tvdetails = (textview) findviewbyid(r.id.tvdetails); intent = getintent(); //haal data van de intents en zet deze in de textview tvdetails.settext(i.getintextra("details", r.string.details_frankrijk)); } public void btnclickme (view v) { textview tvdetails = (textview) findviewbyid(r.id.tvdetails); edittext txtinput = (edittext) findviewbyid(r.id.txtinput); textview lbloutput = (textview) findviewbyid(r.id.lbloutput); edittext txtinput2 = (edittext) findviewbyid(r.id.txtinput2); lbloutput.settext("het land " + tvdetails.gettext().tostring() + " haalt in het ek volgens jou positie " + txtinput.gettext().tostring() + ". je hebt hiervoor " + txtinput2.gettext().tostring() + " euro ingezet."); }
}
for edittext use edittext.setenabled(false);
in combination edittext.setfocusable(false);
for button button.setenable(false)
suffice.
Comments
Post a Comment