简体   繁体   English

Android:画布和onTouchListener

[英]Android:Canvas and onTouchListener

I have an application which has a canvas where I can draw free hand stuff. 我有一个带有画布的应用程序,可以在其中绘制无用的东西。 Now, I would want to display a toast message on the MotionEvent.KEY_UP event which can be handled in the onTouchListener handler. 现在,我想在MotionEvent.KEY_UP事件上显示一条敬酒消息,可以在onTouchListener处理程序中对其进行处理。 As of now I've used console or System.out.println to display my message. 到目前为止,我已经使用console或System.out.println来显示我的消息。 The application force closes if I use Toast. 如果我使用Toast,则应用程序关闭。 Kindly help. 请帮助。

You need to run this on the UI thread. 您需要在UI线程上运行它。

Look at this: http://developer.android.com/resources/articles/painless-threading.html 看看这个: http : //developer.android.com/resources/articles/painless-threading.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM