Android的UI更新 [英] Android update UI

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

问题描述

基本上,此刻我展示( loading.setVisibility(View.VISIBLE); )加载屏幕,然后加载使用的BufferedReader一些外部数据,然后隐藏加载屏幕( loading.setVisibility(View.INVISIBLE); )之后。问题是在载入画面永远不会显示。在code是所有在正确的地方GUI只是因为载入画面再次被设置为不可见并没有等到什么时候这显然是太晚了该方法的最终更新。

Basically at the moment I'm showing a loading screen (loading.setVisibility(View.VISIBLE);) then loading some external data using a "BufferedReader" and then hiding the loading screen (loading.setVisibility(View.INVISIBLE);) afterwards. The problem is the loading screen is never shown. The code is all in the correct place the GUI just doesn't update until the end of the method when it is obviously too late because the loading screen is set to invisible again.

有没有办法强制更新通过方法UI中旬的方式?

Is there any way to force update the UI mid way through a method?

任何帮助将是非常美联社preciated!

Any help would be much appreciated!

推荐答案

不使用后台线程你不能做到这一点。有许多方法可以做到这一点在Android,但最简单的就是使用 AsyncTask的

You can't do this without using a background thread. There are a number of ways you can do this on Android, but the simplest is to use AsyncTask

这是值得一读无痛线程了解更多这方面的信息。

It's worth reading Painless threading for more information on this.

希望这有助于

菲尔Lello

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

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