runOnUIThread问题 [英] runOnUIThread question

查看:132
本文介绍了runOnUIThread问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的ListView一个下载管理器,它会显示由进度下载的电流。我想知道我怎么可以更新进度?

I'm create a download manager with listview and it will display the current downloaded by progressbar. May I know how can i update the progressbar?

例如。我有3类。

main.class=是一个列表视图。

"main.class" = is a listview.

mAdapter.class=是扩展ArrayAdapter。

"mAdapter.class" = is extends ArrayAdapter.

mThread.class=实现Runnable开始下载。

"mThread.class" = implements Runnable to start the download.

我有谷歌,发现更新列表视图,或重绘UI应该使用 runOnUIThread 。但我如何能结合在一起的3类?我试着

I have google, and found to update the listview, or redrawing the UI should use runOnUIThread. but how can i combine those 3 class together? I have try

mThread.start(){
   main.runOnUIThread(updated);
}
private updated = new Runnable(){
   mAdapter.progressbar.setProgress(downloaded);
}

这2方法我被放在mThread.class。但它不工作。我可以知道我是我misstake?

this 2 method i was put in "mThread.class". but it doesn't work. May I know what i was my misstake?

P / S:我对我的丑code和糟糕的英语抱歉。希望你们明白我在说什么。谢谢

P/S:I'm sorry about my ugly code and bad english. Hope you guys understand what I'm talking about. Thanks

推荐答案

您需要使用AsyncTask的。请参阅描述和实例文档。 http://developer.android.com/intl/zh -Tw /参考/安卓/ OS / AsyncTask.html

You need to use the AsyncTask. See the docs for description and examples. http://developer.android.com/intl/zh-TW/reference/android/os/AsyncTask.html

这篇关于runOnUIThread问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆