android中怎么动态更新dialog中的textview

Leo--Wang 2016-06-22 04:02:06
如图 我想更新dialog中这个下载网速和百分比 需要不断更新
代码如下:
View convertView = LayoutInflater.from(
context).inflate(
R.layout.download_dialog, null);
((TextView) convertView
.findViewById(R.id.title_tv))
.setText(R.string.text_downloading);
speed = ((TextView) convertView
.findViewById(R.id.tv_speed));
percent = ((TextView) convertView.findViewById(R.id.tv_pencent));
progressBar = ((ProgressBar) convertView.findViewById(R.id.progressBar));
progressBar.setMax(100);
Builder builder = new AlertDialog.Builder(
context);
m_progressDlg = builder.create();
m_progressDlg.show();
m_progressDlg.setContentView(convertView);
m_progressDlg.setCancelable(false);
m_progressDlg.setCanceledOnTouchOutside(false);
...全文
1072 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Leo--Wang 2016-06-22
  • 打赏
  • 举报
回复
把percent和progressBar定义为成员变量,下载的线程中发送Message,带上网速和进度的参数数据,然后利用Handler处理,拿到数据, 更新percent和progressBar.

80,348

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧