+ -
当前位置:首页 → 问答吧 → 开启APP时使用Progress Dialog能否呈现Loading

开启APP时使用Progress Dialog能否呈现Loading

时间:2011-09-04

来源:互联网

标题 开启APP时使用Progress Dialog能否呈现Loading

最近程式写了一个小段落,回头发现 开启app时要做许多处理(取得资料库资料

作者: polo54786   发布时间: 2011-09-04

:::第一个问题
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
  Button button=(Button)findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { progressDialog=new ProgressDialog(MySource.this); progressDialog.show(); Thread thread=new Thread() { @Override public void run() { super.run();
  //处理程式部份 for(int i=0;i<5;i++) { try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } }
  handler.post(runnable); } }; thread.start(); } }); }
  private ProgressDialog progressDialog; private Handler handler=new Handler(); private Runnable runnable=new Runnable() { @Override public void run() { progressDialog.dismiss(); } }; 

作者: luo673   发布时间: 2011-09-05