标签:set context sage ted trace handle raw 数据 tco
Layout 不要加载大的图片
添加图片 在代码中
constraintLayout = findViewById(R.id.logconstrain);
constraintLayout.setBackground(ContextCompat.getDrawable(getApplicationContext(),R.drawable.logbackground));
子线程
第一种回到住线程更新
import android.os.Handler;
//声明Handle
private Handler handlerd = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
Log.v("Main","s11133sf"+String.valueOf(Thread.currentThread())+"fff"+msg.what+"msg:"+msg);
}
};
//安卓子线程
//子线程耗时操作
new Thread(new Runnable() {
@Override
public void run() {
//耗时操作 发送一次 调用一次
// handlerd.sendEmptyMessage(1);
handlerd.sendEmptyMessage(0);
Message msg =new Message();
msg.obj = "数据";//可以是基本类型,可以是对象,可以是List、map等
handlerd.sendMessage(msg);
}
}).start();
第二种
new Thread(new Runnable() {
@Override
public void run() {
// 写子线程中的操作
try {
Thread.sleep(2);
Log.v("Main","aaafflllkopeeewqqqlllpppaaqqq"+String.valueOf(Thread.currentThread()));
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.v("Main","sdjjjfsf"+String.valueOf(Thread.currentThread()));
}
}).start();
标签:set context sage ted trace handle raw 数据 tco
原文地址:https://www.cnblogs.com/hangman/p/10185340.html