In this example, Icons Only and Icons and marquee have nothing to note.
The Use Remote views in balloon introduces the Layout that can be customized to display Notification in the Extended Status bar. The Extended Status Bar displays Notification as an icon by default, followed by text, which is sufficient in most cases. If needed, you can also use the custom Layout to display the Notification in the Extented Status bar by using RemoteView:
[Java]
Private void setMoodView (int moodId, int textId ){
Notification notif = new Notification ();
Notif. contentIntent = makeMoodIntent (moodId );
CharSequence text = getText (textId );
Notif. tickerText = text;
// The icon for the status bar
Notif. icon = moodId;
// Our custom view
RemoteViews contentView = new RemoteViews (getPackageName (),
R. layout. status_bar_balloon );
ContentView. setTextViewText (R. id. text, text );
ContentView. setImageViewResource (R. id. icon, moodId );
ContentView. setImageViewResource (R. id. icon1, moodId );
Notif. contentView = contentView;
MNotificationManager. Policy (R. layout. status_bar_configurations,
Notif );
}
Private void setMoodView (int moodId, int textId ){
Notification notif = new Notification ();
Notif. contentIntent = makeMoodIntent (moodId );
CharSequence text = getText (textId );
Notif. tickerText = text;
// The icon for the status bar
Notif. icon = moodId;
// Our custom view
RemoteViews contentView = new RemoteViews (getPackageName (),
R. layout. status_bar_balloon );
ContentView. setTextViewText (R. id. text, text );
ContentView. setImageViewResource (R. id. icon, moodId );
ContentView. setImageViewResource (R. id. icon1, moodId );
Notif. contentView = contentView;
MNotificationManager. Policy (R. layout. status_bar_configurations,
Notif );
}
In order to be different from the default Status Bar Layout, we add an ImageView in/res/status_bar_balloon.xml: each icon is displayed on the left and right, with text in the middle.
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "horizontal"
Android: baselineAligned = "false"
Android: gravity = "center_vertical"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content">
<ImageView android: id = "@ + id/icon"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_marginRight = "10dip"/>
<TextView android: id = "@ + id/text"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: textColor = "# ffffffff"/>
<ImageView android: id = "@ + id/icon1 ″
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_marginRight = "10dip"/>
</LinearLayout>
Use default values where applicable describes how to Use the default sound, vibrate, or both:
[Java]
Int default = Notification. DEFAULT_SOUND;
// Notification. DEFAULT_SOUND
// Notification. DEFAULT_VIBRATE
// Notification. DEFAULT_ALL
Notification. defaults = defaults;
Int default = Notification. DEFAULT_SOUND;
// Notification. DEFAULT_SOUND
// Notification. DEFAULT_VIBRATE
// Notification. DEFAULT_ALL
Notification. defaults = defaults;
Author: mapdigit