删除手势生成器中变量的值

delete value on variable in gesture builder

你好,我来自印度尼西亚,很抱歉我的英语不好,我有如下的源代码:

package com.Project.x;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;


public class Main extends Activity implements OnGesturePerformedListener {

EditText showText1;
String txtToDisplay = "";
Button hapus;
Button proses;
GestureLibrary mLibrary;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,     WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.belajar);

    Button tutor =(Button) findViewById(R.id.tutorial);
    tutor.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            Intent a = new Intent(Main.this, Tutorial.class);
            startActivity(a);
        }

    });

    Button btn =(Button) findViewById(R.id.delete);
    btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                EditText showText1 = (EditText) findViewById(R.id.hasil);
                showText1.getText().toString();
                showText1.setText("");
            }       
    });

showText1 = (EditText) findViewById(R.id.hasil);
mLibrary = GestureLibraries.fromRawResource(this,R.raw.gestures5);
if(!mLibrary.load()) {
    finish();
}


final GestureOverlayView gestureOverLay1 = (GestureOverlayView)
findViewById(R.id.gestureOverlayView1);
gestureOverLay1.addOnGesturePerformedListener(this);


}

public void onGesturePerformed(GestureOverlayView overlay, Gesture gestures5) {
    ArrayList<Prediction>predictions=mLibrary.recognize(gestures5);
    if(predictions.size()>0){
        Prediction prediction = predictions.get(0);
        if(prediction.score>1.0){
            `txtToDisplay+=prediction.name;
        } else {
            showText1.setText("karakter tidak ditemukan :( ");
                                }
                            }
}
}

这是一个简单的 gestureoverlay 手势,与我之前所做的手势同步。如果我写一封信(例如:B O O K),程序输出将显示在编辑文本中,问题出在删除按钮上。我想一个一个地删除字符串变量中的值,但我不知道确切的代码。也许任何人都可以给我代码,每个答案都对我很有帮助。在此之前感谢

Button btn =(Button) findViewById(R.id.delete);
btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            EditText showText1 = (EditText) findViewById(R.id.hasil);
           String string= showText1.getText().toString();
            if (string == null || string.length() == 0) {
           string="";
        }
        else
        string= string.substring(0, string.length()-1);
        }


            showText1.setText(string);
        }       
});