Android Apidemos Sample resolution: App->notification->status Bar

Source: Internet
Author: User

This example is Icons only and Icons and marquee are not particularly well illustrated.

The use Remote views in balloon describes the layout,extended status bar that can be customized to display notification in Extended status bar The default display notification is an icon After the text, corresponding to most of the situation is enough. However, if necessary, you can also use a custom layout to display notification in extented Status bar by RemoteView:

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); C10/>contentview.settextviewtext (r.id.text, text);
 Contentview.setimageviewresource (R.id.icon, moodid);
 Contentview.setimageviewresource (R.id.icon1, moodid);
 Notif.contentview = Contentview;

 Mnotificationmanager.notify (r.layout.status_bar_notifications, 
 notif);
}

To make a difference from the default status Bar layout, we add a imageview in/res/status_bar_balloon.xml: The left and right sides show an icon 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 the method of using the defaults sound, vibration, or both:

int default = Notification.default_sound;     
Notification.default_sound
//notification.default_vibrate
//notification.default_all

Notification.defaults = defaults;

Note: The same notification id:r.layout.status_bar_notifications is used in the example, so each call to the Mnotificationmanager.notify will update the same notification.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.