2010-12-21 56 views
13

我使用AsyncTask爲我的Listview下載圖片,因爲我不想下載圖片來阻止我的UI線程。在加載圖像時,我想在圖像所在的位置顯示動畫進度圈。Android:在Google應用中顯示像Google一樣的進度圈

但我找不到進展圈的圖片。什麼是資源ID?或者還有其他方法嗎?有人有鏈接到這個圖像?

回答

22

看那progress bar。它可以在不確定模式下工作(並且它默認爲AFAIR),這意味着它會顯示一個旋轉的圓圈,就像您要求的那樣。我知道這不是一個圖像,但你可以做的是放置一個FrameLayout而不是圖像,進度條是唯一的孩子。然後,一旦圖像加載完成,刪除進度欄並添加圖像。

+0

這個建議很好 - 我只是自己試了一下。根據圖像數量的不同,它可能會非常繁瑣,但除非有人提供內置旋轉進度條的res ID,否則這似乎是一個不錯的方法。 – Squonk 2010-12-22 02:40:41

11

這個定義一個全局變量ProgressDialog pd;

就在launche的的AsyncTask做:

pd = ProgressDialog.show(CurrentClassName.this,"This is the title","This is the detail text",true,false,null); 

當其完成onPostExecute就叫pd.dismiss();

更多細節看看:ProgressDialog

你必須特別考慮它才能工作在對話框啓動時旋轉設備。

+0

我只想circly顯示進度,沒有任何文字... – 2010-12-21 22:51:37

+0

是啊,我誤解了。 – blindstuff 2010-12-22 01:40:00

3

你想要一個不確定的ProgressBar。看看開發者的網站 -

ProgressBar

5

這是介紹性的佈局文件,圖像和圓形進度條的例子:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:contentDescription="@string/intro_description" 
     android:scaleType="fitXY" 
     android:src="@drawable/intro" /> 

    <ProgressBar 
     android:id="@+id/progress" 
     style="?android:attr/progressBarStyleInverse" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="150dp" 
     android:visibility="visible" /> 

</FrameLayout> 
相關問題