繁体   English   中英

使用进度条指示在下载图像的过程中

[英]use progressbar to indicate in the course of downloading image

以下是我的布局:

<FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ProgressBar
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" /> 

    <ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>           
</FrameLayout>

我试图下载给定url链接的图像,然后在ImageView上显示该图像。 在准备好图像之前, ProgressBar显示在ImageView 到目前为止,我的代码可以下载图像并将其显示在ImageView 由于下载需要时间,因此在图像出现之前会有明显的延迟。 谁能给我一些建议? 我是android新手,这不是家庭作业。

您需要使用AsyncTask ...这是一个很好的教程:

http://www.androidhive.info/2012/04/android-downloading-file-by-showing-progress-bar/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM