我正在实施在线手写识别作为我的BE项目。我创建了一个扩展Fragments的类。片段类包含两个按钮和一个GestureOverlayView。 我已将其strokeType设为MULTIPLE。
我想提取笔画的x和y坐标。但找不到办法.... 我只创建了一个GestureOverlayView实例
package com.example.enotebook;
import java.util.ArrayList;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGestureListener;
import android.gesture.GesturePoint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
public class WArea extends Fragment implements OnGestureListener {
private ArrayList<GesturePoint> gpoint;
private int count;
private Button b;
private TextView text;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View wView = inflater.inflate(R.layout.fragment_writing, container, false);
b = (Button) wView.findViewById(R.id.done);
//Creating TextView Variable
text = (TextView) wView.findViewById(R.id.textView1);
return wView;
}
@Override
public void onGesture(GestureOverlayView gesture, MotionEvent event) {
gpoint = gesture.getCurrentStroke();
count = gpoint.size();
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Sets the new text to TextView (runtime click event)
text.setText("You Have click the button -"+count);
}
});
}
@Override
public void onGestureCancelled(GestureOverlayView gesture, MotionEvent event) {
gpoint = gesture.getCurrentStroke();
count = gpoint.size();
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Sets the new text to TextView (runtime click event)
text.setText("You Have click the button -"+count);
}
});
}
@Override
public void onGestureEnded(GestureOverlayView gesture, MotionEvent event) {
gpoint = gesture.getCurrentStroke();
count = gpoint.size();
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Sets the new text to TextView (runtime click event)
text.setText("You Have click the button -"+count);
}
});
}
@Override
public void onGestureStarted(GestureOverlayView gesture, MotionEvent event) {
gpoint = gesture.getCurrentStroke();
count = gpoint.size();
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Sets the new text to TextView (runtime click event)
text.setText("You Have click the button -"+count);
}
});
}
}
我是android和java的新手.....
请帮助......