i want to place edit text on tap on canvas. i want to take input from user and set that edit text to canvas.
here is my code:
@Override
protected void onDraw(Canvas canvas) {
for (Point point : points) {
LinearLayout lL = new LinearLayout(getContext());
EditText editTextView = new EditText(getContext());
editTextView.setFocusableInTouchMode(true);
editTextView.setFocusable(false);
editTextView.setClickable(true);
editTextView.setText("sadsdadadadadsadasds");
editTextView.setVisibility(View.VISIBLE);
lL.addView(editTextView);
lL.setDrawingCacheEnabled(true);
lL.measure(canvas.getWidth(), canvas.getHeight());
lL.layout(0, 0, canvas.getWidth(), canvas.getHeight());
canvas.drawBitmap(lL.getDrawingCache(), point.x, point.y, mPaint);
// canvas.drawText("(0,0)", point.x, point.y, mPaint);
// Log.d(TAG, "Painting: "+point);
}
}
@Override
public boolean onTouch(View v, MotionEvent event) {
float x = event.getX();
float y = event.getY();
InputMethodManager inputMethodManager;
TextView tv1=new TextView(getContext());
LinearLayout lL = new LinearLayout(getContext());
// return super.onTouchEvent(event);
Point point = new Point();
point.x = (int) event.getX();
point.y = (int) event.getY();
points.add(point);
invalidate();
return true;
}
Error:
PROBLEM is that EditText is Getting placed on Canvas but not clickble