編輯:關於Android編程
曾經遇到過這樣的問題,在我的代碼中使用了通知欄,一切都正常,但是就是正在進行的通知欄中屬於我的程序的那一條總是上下跳來跳去,一閃一閃的。感覺用戶體驗很不好,於是Google一下,找到了解決方法。
在我的代碼,我是這樣寫的。
復制代碼 代碼如下:
notification.when = System.currentTimeMillis();
這就是問題的關鍵,對於通知來說,when這個屬性值應該在activity一啟動的時候就應該固定。如果沒有固定,就會使用默認的值,默認的值就是當前的時間,即System.currentTimeMillis()的值。因此使用一個自定義的固定值就可以解決問題。
復制代碼 代碼如下:
final long TIMESTAMP_FIXED = 1234567890l;
notification.when = TIMESTAMP_FIXED;
以下如Google介紹如何使用notification的when的說明。
復制代碼 代碼如下:
A timestamp related to this notification, in milliseconds since the epoch. Default value: Now. Choose a timestamp that will be most relevant to the user. For most finite events, this corresponds to the time the event happened (or will happen, in the case of events that have yet to occur but about which the user is being informed). Indefinite events should be timestamped according to when the activity began. Some examples:
Notification of a new chat message should be stamped when the message was received.
Notification of an ongoing file download (with a progress bar, for example) should be stamped when the download started.
Notification of a completed file download should be stamped when the download finished.
Notification of an upcoming meeting should be stamped with the time the meeting will begin (that is, in the future).
Notification of an ongoing stopwatch (increasing timer) should be stamped with the watch's start time.
Notification of an ongoing countdown timer should be stamped with the timer's end time.
Reference
http://developer.android.com/reference/android/app/Notification.html#when
自繪控件的內容都是自己繪制出來的 大致流程如下:1.定義一個類繼承view 1.使用TypedArray初始化屬性集合 在
前言在Android開發中,顏色資源分兩種:一種是自定義顏色,一種是使用系統給我們自帶的顏色自定義顏色Android中顏色值的定義是由透明度alpha和RGB(紅綠藍)三
在Android系統自帶的設置功能裡,進入應用列表後,點擊列表條目會進入應用的詳情界面。那麼我們自己可不可以寫一個自己的應用程序,實現激活應用程序的詳情界面呢?這個是可以
RecyclerView 已經出來很久了,但是在項目中之前都使用的是ListView,最近新的項目上了都大量的使用了RecycleView.尤其是瀑布流的下拉刷新,網上吧