android.os.Handler

作者:追风剑情 发布于:2015-1-25 0:56 分类:Android

  1. Handler myHandler = new Handler() {
  2. //此方法会在ui线程中执行
  3. public void handleMessage(Message msg) {
  4. Context context = getApplicationContext();
  5. CharSequence text = "Hello Handler! what="+msg.what;
  6. int duration = Toast.LENGTH_LONG;
  7. Toast.makeText(context, text, duration).show();
  8. }
  9. };
  10. Message msg = new Message();
  11. msg.what = 1;
  12. myHandler.dispatchMessage(msg);

标签: Android

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号