知识库

个人知识管理

用户工具

站点工具


安卓开发:handler的常见用法

Android中Handler的常见用法

static class MyHandler extends Handler {
    WeakReference<Activity > mActivityReference;
 
    MyHandler(Activity activity) {
        mActivityReference= new WeakReference<Activity>(activity);
    }
 
    @Override
    public void handleMessage(Message msg) {
        final Activity activity = mActivityReference.get();
        if (activity != null) {
            mImageView.setImageBitmap(mBitmap);
        }
    }
}
安卓开发/handler的常见用法.txt · 最后更改: 2019/09/11 00:49 (外部编辑)