화면에 제스처를 사용하여 "test"라는 단어를 작성한 다음 문자 (t, e, s, t)로 분할하고 싶다고 가정합니다. 나는 그것을 위해 구글을 검색했지만 제스처를 사용하여 단어를 작성한 다음 단어에서 문자를 분할하는 데 도움이되는 링크를 찾지 못했습니다.이 주제에 대한 유용한 링크 나 튜토리얼은 감사 할 것입니다 .. (현재 나는 다음에서 문자 만 쓰는 코드를 작성합니다. a time, a word ca n't, and then how to segment this text I ca n't (이해할 수없는 텍스트를 분할하는 방법)
내 코드는
public class GestureTest extends Activity implements OnGesturePerformedListener {
private static GestureLibrary gesturerLib;
TextView showText1;
TextView showText2;
EditText firstEditText;
ArrayList<String> bindList;
ArrayList<Prediction> result;
ListView listViewShow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_gesture_test);
GestureOverlayView gestureOverLayerView = new GestureOverlayView(this);
//View inflate = getLayoutInflater().inflate(R.layout.activity_gesture_test,null);
View inflate = getLayoutInflater().inflate(R.layout.activity_gesture_test,null);
gestureOverLayerView.addView(inflate);
gestureOverLayerView.addOnGesturePerformedListener(this);
gesturerLib = GestureLibraries.fromRawResource(getApplicationContext(), R.raw.gestures);
if(!gesturerLib.load()){
finish();
}
setContentView(gestureOverLayerView);
}
@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// TODO Auto-generated method stub
showText1 = (TextView)findViewById(R.id.listView1);
result = gesturerLib.recognize(gesture);
String point=null;
String firstLetter=null;
StringBuffer sb = new StringBuffer();
String value1 = "";
if(result.size() > 0 && result.get(0).score>1.0){
value1 += result.get(0).name;
for(int j= 0;j< prescriptionNames.length;j++){
// prescriptionName is String[]
firstLetter = prescriptionNames[j];
Log.i("THE STRING[] VALUE",firstLetter );
if( firstLetter.startsWith(value1)){
showText1.setText(firstLetter);
}
}
}
예를 들어 링크 https://play.google.com/store/apps/details?id=com.visionobjects.stylusmobile.v3_2_store
화면에 단어를 쓰고 싶어요 예 : 화면에 테스트를 쓰지만 두 번째 글자를 쓰면 t 만 쓸 수 있습니다 e, 첫 글자가 사라집니다. 그게 내 문제입니다
이해할 수 있기를
그것이 가능하거나 잘못되었다고 말 해주세요.
활동에서 :
GestureLibrary gLibrary;
GestureOverlayView mView;
String txtToDisplay="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (gLibrary != null) {
if (!gLibrary.load()) {
Log.e("GestureSample", "Gesture library was not loaded…");
finish();
} else {
mView = (GestureOverlayView) findViewById(R.id.gestures);
mView.addOnGesturePerformedListener(this);
}
}
}
@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = gLibrary.recognize(gesture);
// one prediction needed
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
// checking prediction
if (prediction.score > 1.0) {
txtToDisplay+=prediction.name;
yourTextView.setText(txtToDisplay);
}
}
}
}
XML에서 제스처를 인식하려는 위치에 다음을 배치해야합니다.
<android.gesture.GestureOverlayView
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gestureColor="#2a69a5"
android:uncertainGestureColor="#e2e2e2" >
</android.gesture.GestureOverlayView>
그리고 제스처 라이브러리가 필요합니다. 이 자습서의 첫 번째 단계를 따르십시오. Android 제스처 자습서
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다