//使用handler进行跟新视图
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
Bundle bundle = msg.getData();
String color = bundle.getString("color");
//你的TextView
textView.setText(color);
}
};
new Thread(new Runnable() {
@Override
public void run() {
Message msg = new Message();
Bundle bundle = new Bundle();
bundle.putString("color", "黄色");
msg.setData(bundle);
handler.sendMessage(msg);
}
}).start();
new Thread(new Runnable() {
String text;
@Override
public void run() {
try {
Document document = Jsoup.connect("https://www.baidu.com/").get();
System.out.println(document);
list.add(document.title());
list.add("111");
runOnUiThread(new Runnable() {
@Override
public void run() {
recyclerView.setAdapter(new RecyclerBaseAdapter(list, R.layout.fragment_list));
recyclerView.setItemAnimator(new DefaultItemAnimator());
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(ScrollingActivity.this, DividerItemDecoration.VERTICAL);
Drawable drawable = ContextCompat.getDrawable(ScrollingActivity.this, R.color.colorAccent);
dividerItemDecoration.setDrawable(drawable);
recyclerView.addItemDecoration(dividerItemDecoration);
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();