开发者

Android:How create ongoing notification with progress bar?

i am using a service in order to play background music, and i want to create an on going notification with progress bar ,on status bar, in order to user ca开发者_运维问答n watch the progress of current track. Can somebody help me? Thank you very much ...


Create a custom Notification and put something like this in your notification_layout.xml file:

<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" />

Keep a reference to your Notification (make it global) and set the progress using RemoteView's API.

Sample code:

mNotification.contentView.setProgressBar(R.id.notificationLoadingBar,
    max, progress, false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜