1.ctrl+alt+s 打开设置,搜索live temp
2. Define选择java.填好上面几个信息就可以用了.
3. 最后我的效果图
4. 几个模版
(1) 弱引用handler
//handler
public static class MyHandler extends Handler {
public final WeakReference<$className$> mWeakReference;
public MyHandler($className$ activity) {
mWeakReference = new WeakReference<>(activity);
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
$className$ activity = mWeakReference.get();
if (msg.what == $code$) {
if (activity != null) {
}
}
}
}
(2)单例
//singleton
private volatile static $className$ sInstance;
public static $className$ getInstance() {
if (sInstance == null) {
synchronized ($className$.class) {
if (sInstance == null) {
sInstance = new $className$();
}
}
}
return sInstance;
}
private $className$() {
}
最后编写代码的时候输入快捷键就可以了