jersam515
jersam515

Reputation: 657

Is my OnTouchEvent() for android SDK not working correctly?

So I'm making a simple painting app for the Android SDK. However, the onTouchEvent() is only getting some of the events not all of them(if I drag my finger across the screen it gets roughly half of the events(points)) Here is my OnTouchEvent():

@Override
public boolean onTouchEvent(MotionEvent event) {
    mDbHelper.createNote(event.getX(), event.getY(), 11);
    NotesMade ++;
    mLemonadeMainMenuView.setCoords(NotesMade);
        return true;
}


private void doDraw(Canvas canvas) {
          canvas.drawColor(Color.TRANSPARENT);
            Paint paint = new Paint();
            paint.setColor(Color.BLUE);
            paint.setStyle(Style.FILL);
            int mNoteId = 0;
             while(mNotesMade>mNoteId)
                {mNoteId++;
                 Cursor note = mDbHelper.fetchNote(mNoteId);
                 Float x;
                 Float y;
                 Float size;
                 x = Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_X)));
                 y= Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_Y)));
                 size = Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_Size)));
          canvas.drawCircle(x, y, size, paint);}
    }}                                               

Drawing portion above. Logcat also reveals nothing. Help would be greatly appreciated. How can I fix my OnTouchEvent()?

Upvotes: 0

Views: 318

Answers (1)

Zaid Daghestani
Zaid Daghestani

Reputation: 8615

You haven't done anything wrong. There is no way of increasing the sampling rate of touch input. You'll have to calculate points in between each sample.

Upvotes: 1

Related Questions