2012-01-19 33 views
0

我爲我的應用程序創建了一個放屁聲音板。我對開發很陌生,這是我的第一個應用程序。當點擊使用onClick button_sound.start方法時,我有一堆播放聲音的按鈕。如何僅在通過xml播放聲音時才顯示旋轉進度條?這是我的代碼:音樂播放時如何顯示ProgressBar微調器?

 <?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:background="@raw/nuke" 
    android:padding="8dp"> 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:text="Click a button to play a fart!" 
    android:textColor="#FF0000" 
    android:textSize="24dp" /> 
<SeekBar 
    android:id="@+id/sbVolume1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" /> 

<Button 
    android:id="@+id/ranfart" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Random Fart" 
    android:textColor="#0B0B61" 
    android:textSize="21dp" /> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" >  
<Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Fart 1" 
    android:layout_weight="50" 
    android:textSize="21dp" 
    android:id="@+id/fart1" 
    android:textColor="#0B0B61"/> 
<Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Fart 2" 
    android:layout_weight="50" 
    android:textSize="21dp" 
    android:id="@+id/fart2" 
    android:textColor="#0B0B61" 
    /> 
</LinearLayout> 
</LinearLayout> 
</ScrollView> 

如何在聲音播放期間製作旋轉進度加載程序? 而且我怎樣才能讓我的按鈕的旋轉progressBar ONTOP? (不是上面,不是下面,但是ONTOP?

回答

0

你想要一個ProgressBar或者SeekBar嗎?聽起來你想要一個ProgressBar,但是你在你的XML中包含了一個SeekBar,無論如何,你應該通過this example on merging two layouts ,它會幫助你在另一個顯示器上顯示一些東西,至於只在你播放聲音時才顯示ProgrssBar,如果你讓我們看到你正在使用的一些代碼,它將幫助所有人解決問題。是不同的方式來播放聲音,因此不同的方式來實現你的目標。

+0

我想要一個進度條。seekbar是我的卷,我已經設置了我只需要知道如何讓進度條只在音樂正在播放,我現在不在我的計算機上,所以我不能顯示你的代碼,但我的java看起來很棒hing是這樣的:fart1.setonClickListener(new view.onclicklistener)..... bla bla .....並且我有Fart1.start(); (我在早些時候在Java中將Fart1設置爲聲音) – user1157306