0
我正在使用服務來播放背景音樂,並且我想用狀態欄上的進度條創建一個正在進行的通知,以便用戶可以觀看當前曲目的進度。有人能幫助我嗎?非常感謝您......Android:如何通過進度條創建正在進行的通知?
我正在使用服務來播放背景音樂,並且我想用狀態欄上的進度條創建一個正在進行的通知,以便用戶可以觀看當前曲目的進度。有人能幫助我嗎?非常感謝您......Android:如何通過進度條創建正在進行的通知?
創建custom Notification
,並把這樣的事情在你的notification_layout.xml文件:
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="15dp"
android:id="@+id/notificationLoadingBar"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminate="false"
android:indeterminateOnly="false" />
保持對它的引用您的Notification
(使它全球),並設置使用RemoteView
進度的API。
示例代碼:
mNotification.contentView.setProgressBar(R.id.notificationLoadingBar,
max, progress, false);
非常感謝你,我的作品,現在我想以我的更新進度條來創建我的服務類中的線程。你知道我怎麼能創建一個服務類的線程。謝謝... – Tim
@Tim:使用['AsyncTask'](http://developer.android.com/reference/android/os/AsyncTask.html) – Wroclai