java - Using gesture control -
im learning how use gesture builder recognize gestures , use them in development.
this snippet of code :
public void ongestureperformed(gestureoverlayview overlay, gesture gesture) { arraylist<prediction> predictions = olib.recognize(gesture); // want @ least 1 prediction final edittext et_text = (edittext) findviewbyid(r.id.edittext1); if (predictions.size() > 0) { prediction prediction = predictions.get(0); if (prediction.score > 0.1) { // work //toast.maketext(this, prediction.name, toast.length_short) //.show(); string s ="o"; if (prediction.name == s) { et_text.settext("o"); toast.maketext(this, "test", toast.length_short) .show(); } } } }
i got gesture called o , idea when make gesture type o in edittext cant figure out why dosent ?
it recognizes gesture in first second if (score >0.1) not in 1 blow.
any idea why ?
do not compare strings
==
; problem. compare strings
, use .equals()
method., aka: if (s.equals(prediction.name))
in short, ==
compares references, whereas .equals()
compares the contents of strings
. go more detail, has been covered in many threads, for example.
Comments
Post a Comment