3

通知バーにアイコンを表示しようとしています。 アイコンはレベルを設定してコンテンツを変更できるLevelListDrawableです。 問題は通知のアイコンにレベルを設定できないことです。 "Notification.icon"と "Notification.iconLevel"を使用しようとしましたが、動作しません。通知バーにLevelListDrawableを表示

ここは私のコードです。誰が間違っているのを見ることができますか?ここで

Notification notification = new Notification(R.drawable.ic_stat_notify, "", System.currentTimeMillis()); 
notification.icon = R.drawable.ic_stat_notify; 
notification.iconLevel = 30; 
notification.setLatestEventInfo(context, "Hello", "World", intent); 
manager.notify(NOTIFICATION_ID, notification); 

は、あなたが展開通知リストで通知のための特定のアイコンを表示したい場合は、あなたがiconLevelなしとの「通常」描画可能で、通知を作成する必要があり、私のLevelListDrawable

?xml version="1.0" encoding="utf-8"?> 
level-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:drawable="@drawable/ic_stat_notify_0" 
     android:minLevel="0" 
     android:maxLevel="9"/> 
    <item android:drawable="@drawable/ic_stat_notify_10" 
     android:minLevel="10" 
     android:maxLevel="11"/> 
    <item android:drawable="@drawable/ic_stat_notify_20" 
     android:minLevel="20" 
     android:maxLevel="29"/> 
    <item android:drawable="@drawable/ic_stat_notify_30" 
     android:minLevel="30" 
     android:maxLevel="39"/> 
    <item android:drawable="@drawable/ic_stat_notify_40" 
     android:minLevel="40" 
     android:maxLevel="49"/> 
    <item android:drawable="@drawable/ic_stat_notify_50" 
     android:minLevel="50" 
     android:maxLevel="59"/> 
    <item android:drawable="@drawable/ic_stat_notify_60" 
     android:minLevel="60" 
     android:maxLevel="69"/> 
    <item android:drawable="@drawable/ic_stat_notify_70" 
     android:minLevel="70" 
     android:maxLevel="79"/> 
    <item android:drawable="@drawable/ic_stat_notify_80" 
     android:minLevel="80" 
     android:maxLevel="89"/> 
    <item android:drawable="@drawable/ic_stat_notify_90" 
     android:minLevel="90" 
     android:maxLevel="99"/> 
    <item android:drawable="@drawable/ic_stat_notify_100" 
     android:minLevel="100" 
     android:maxLevel="100"/> 
</level-list> 
+0

レベルリストのXMLを投稿してください。 –

+2

ステータスバーのアイコンがレベルで正しいことがわかりました。しかし、ドロワーの通知ビューで間違っています。 – Dennis

答えて

1

ですまず別のアイコン(レベルリストなど)を設定してiconLevelを設定することができます。

ステータスバーに

notification.icon = R.drawable.ic_stat_notify; 
    notification.iconLevel = 30; 
    manager.notify(NOTIFICATION_ID, notification); 

をアイコンを更新するためには、アップデートが見えるようにする)(通知を呼び出すことが重要だ、とあなたは通知を再作成しない限り、展開されたリスト内のアイコンを更新しません。

0

これは、このの可能複製である: android Notification setSmallIcon with level-list

Androidのバグのように見えます。レベルリストを使用して通知を更新すると、ステータスバーアイコンは更新されますが、通知プルダウンのアイコンは更新されません。それはここに報告されています:http://code.google.com/p/android/issues/detail?id=43179&q=setSmallIcon&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

関連する問題