public
class
MainActivity
extends
Activity {
02
03
private
final
static
int
CHANGE =
1
;
04
05
TextView textView;
06
07
Handler handler =
new
Handler(){
08
09
@Override
10
void
handleMessage(Message msg) {
11
switch
(msg.what) {
12
case
CHANGE :
13
textView.setText(msg.obj +
""
);
14
}
15
16
17
};
18
19
20
onCreate(Bundle savedInstanceState) {
21
super
.onCreate(savedInstanceState);
22
setContentView(R.layout.activity_main);
23
textView = (TextView) findViewById(R.id.hello);
24
25
26
Thread() {
27
28
run() {
29
for
(
i=
0
;i<
100
;i++) {
30
try
{
31
Thread.sleep(
1000
32
catch
(InterruptedException e) {
33
e.printStackTrace();
34
35
Message msg =
Message();
36
msg.what = MainActivity.CHANGE;
37
msg.obj = i;
38
MainActivity.handler.sendMessage(msg);
39
40
41
}.start();
42
43
01
TextView text2;
TextView text5;
text2.setText(msg.obj +
text5.setText(msg.obj +
Dialog dialog =
Dialog(
this
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle(
"test"
text2 = (TextView) dialog.findViewById(R.id.text2);
text5 = (TextView) dialog.findViewById(R.id.text5);
dialog.show();
44
45
46
47
48
49
50
51
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- axer.cn 版权所有 湘ICP备2023022495号-12
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务