How to go about having a button and a custom paint view on the same screen? android

I am pretty new to android and am trying to build an app where the user can draw a letter, press a button that connects a service that reads it, and then the letter is displayed back to them. This is my main layout: !( I want the user to be able to draw in the blue area. I made the blue area a custom view called InnerDrawingView. I need help on how to organize the views and the OnTouchListener. Right now I have this java code: public class DoodleActivity extends Activity { Button confirmButton; EditText drawingResult; InnerDrawingView innerView; // on create protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_doodle); // main layout // where the drawing happens innerView = (InnerDrawingView) findViewById(; innerView.setOnTouchListener(handleTouch); ... ... // handle the touching of the inner view private OnTouchListener handleTouch = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { drawingResult.setText("O RLY?!"); // just a test return true; } }; // end of class Is this the correct way to go about it? What kind of touch listener do I put in the InnerDrawingView class? Can I just call: innerView.onTouch() from inside my main activity's onTouch()? Or the onDraw() method? If someone could direct me to a good paint tutorial also that would help me a lot. Thanks for the input.

以上就是How to go about having a button and a custom paint view on the same screen? android的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准