I am using GestureOverlayView to draw any picture I have implemented it successfully,but when i want to draw another picture, I need to clear the previous from the GestureOverlayView in my activity.How can I do it ?
Please look into my code :
public class MainActivity extends Activity {
private Button button_save;
private Button button_clear;
private GestureOverlayView gesture;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gesture = (GestureOverlayView) findViewById(R.id.gestures);
button_save = (Button) findViewById(R.id.save_button);
button_clear = (Button) findViewById(R.id.clearbtn);
button_save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
try {
Bitmap gestureImg = gesture.getGesture().toBitmap(100, 100,
8, Color.BLACK);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
gestureImg.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bArray = bos.toByteArray();
Intent intent = new Intent(MainActivity.this,
Activity2.class);
intent.putExtra("draw", bArray);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(MainActivity.this, "No draw on the string",
3000).show();
}
}
});
button_clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
**//What to do here to clear my drawn animation**
}
});
}
These two lines will clear the created gesture from your activity
gesture.cancelClearAnimation();
gesture.clear(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With