android.os.Handler

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

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

标签: Android

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号