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

推荐订阅源

Know Your Adversary
Know Your Adversary
小众软件
小众软件
L
LangChain Blog
月光博客
月光博客
博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
MongoDB | Blog
MongoDB | Blog
Recorded Future
Recorded Future
V
Visual Studio Blog
TaoSecurity Blog
TaoSecurity Blog
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
D
DataBreaches.Net
L
LINUX DO - 热门话题
C
Check Point Blog
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
The Hacker News
The Hacker News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
博客园 - 司徒正美
T
Threatpost
P
Palo Alto Networks Blog
A
About on SuperTechFans
Spread Privacy
Spread Privacy
Engineering at Meta
Engineering at Meta
N
News | PayPal Newsroom
T
Tailwind CSS Blog
The Last Watchdog
The Last Watchdog
Blog — PlanetScale
Blog — PlanetScale
A
Arctic Wolf
量子位
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园 - 聂微东
Google Online Security Blog
Google Online Security Blog
Google DeepMind News
Google DeepMind News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Vulnerabilities – Threatpost
H
Hacker News: Front Page

博客园 - 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.进度条资源被占用,不能转动