android - Match user input with string -
this more simple thing apologise if is, cannot seem implement it.
i trying check user types edittext field , compare against hard coded string.
here string want compare against -
overlayitem overlayitem = new overlayitem(point,"house information", "4 bed w/ large garden\n2 minute walk town centre\nschools 5 minute walk\n€300,000"); here edittext field -
<!-- number of rooms text field --> <edittext android:id="@+id/numberrooms" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="no. of rooms" android:imeactionlabel="launch" android:inputtype="number" /> i want able check user types against "4" in string. here have attempted far -
edittext numberofrooms = (edittext) findviewbyid(r.id.numberrooms); if(overlayitem.equals(numberofrooms.gettext().tostring())) { itemizedoverlay.addoverlay(overlayitem); } so don't want compare whole string, want compare user enters first character in string, in case number.
try:
string rooms = overlayitem.getsnippet().substring(0,2); rooms = rooms.trim(); if(rooms.equals(numberofrooms.gettext().tostring())) { //do whatever want }
Comments
Post a Comment