惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CERT Recently Published Vulnerability Notes
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
Cisco Talos Blog
Cisco Talos Blog
P
Proofpoint News Feed
H
Heimdal Security Blog
Help Net Security
Help Net Security
H
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
The GitHub Blog
The GitHub Blog
博客园_首页
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - 【当耐特】
J
Java Code Geeks
S
SegmentFault 最新的问题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
O
OpenAI News
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
B
Blog RSS Feed
V2EX - 技术
V2EX - 技术
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tenable Blog
PCI Perspectives
PCI Perspectives
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Hacker News
The Hacker News
Schneier on Security
Schneier on Security
Google Online Security Blog
Google Online Security Blog
美团技术团队
G
GRAHAM CLULEY
D
DataBreaches.Net
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
W
WeLiveSecurity
Vercel News
Vercel News
S
Security Affairs
T
Tailwind CSS Blog
V
Vulnerabilities – Threatpost
博客园 - 司徒正美
G
Google Developers Blog
D
Docker
Webroot Blog
Webroot Blog

博客园 - lodestar

一张图掌握数据存储 使用xtrabackup实现mysql定时热备份 开发篇1:使用原生api和Langchain调用大模型 预热篇2:从RNN到Transformmer 预热篇1:大模型训练显卡选型 macbook安装scala、hadoop、saprk环境 centos6.5 squid安装 一次linux服务器黑客入侵后处理 linux上搭建svn服务器 Windows系统下Oracle每天自动备份 android中listView的几点总结 使用template method模式简化android列表页面 andorid定时器应用 - lodestar Android网络应用(第一部分) - lodestar 错误数据导致java.lang.IllegalArgumentException:Unsupported configuration attributes 使用ACEGI搭建权限系统:第三部分 acegi安全框架使用:第二部分 使用ACEGI实现权限控制,第一部分 ajax实现用户名存在校验
andorid进度条使用
lodestar · 2012-05-31 · via 博客园 - lodestar

关于android进度条

初始化页面时,如果需要从数据库加载数据等消耗时间的操作,一般都需要进度条,这里是进度条使用的2种方式比较
实现方式1:
进入页面后弹出进度条,异步加载数据完毕后关闭并渲染页面
代码大致如下:
// 进度条
myDialog = ProgressDialog.show(this, "请稍等片刻", "正在请求数据中", true, true);
//异步加载数据
Thread lodeThread = new Thread(new LodeStationHandler());
lodeThread.start();

//
private Handler handler = new Handler() {
  @Override
  public void handleMessage(Message msg) {
   switch (msg.what) {
   case 消息值:
    if (myDialog != null) {
     myDialog.dismiss();
    }
    
    //渲染页面
    break;
   }
  }
 };  
我一般都采用这种方法,优点是异步加载数据,避免数据量稍大造成的UI主线程超时报错,而且没有方式2的问题
              

实现方式2:
在上个页面就打开进度条,这时两种选择:1.在离开上个页面时关闭进度条;2.网上见有人在下个页面初始化后关闭上个页面的进度条,没试过
//关闭的handler
private Handler handler = new UIHander();
 private final class UIHander extends Handler {
  public void handleMessage(Message msg) {
   switch (msg.what) {
   case EVENT_TIME_TO_CHANGE_IMAGE:
    if (myDialog != null) {
     myDialog.dismiss();
    }
    break;
   }
  }
 }

//开启进度条
myDialog = ProgressDialog.show(MainMenuActivity.this, "",
       "loading...", true, true);
//进下一个activity
startActivity(intentPage);

message = handler.obtainMessage(EVENT_TIME_TO_CHANGE_IMAGE);
     handler.sendMessage(message);   
问题:1.startActivity本身并不是耗时操作,耗时操作主要是在页面初始化的时候获得数据,下个页面会有一段时间黑屏或只有背景
   2.进度条资源被占用,不能转动