"Sailing plan 026" 2015 sail plan Android Apidemo The Devil step of the App->notification->status bar status bar displays a customized notification layout that saves sound, vibration

Source: Internet
Author: User

This example of Icons only and Icons and marquee nothing particularly good to illustrate.

While the use Remote view in balloon describes the layout,extended status bar which can be customized at Extended status bar display notification notification is an icon followed by text, corresponding to most cases is sufficient. However, if necessary, you can use the custom layout to display the notification in the Extented Status bar by RemoteView:

    Private voidSetmoodview (intMoodid,intTextid) {        //Instead of the normal constructor, we ' re going to use the one with no args and fill//In the data ourselves.        The normal one uses the default layout for notifications. //You probably want so in the most cases and if you want to do something custom, you//can set the Contentview field to your own Remoteviews object.Notification Notif =NewNotification (); //This was who should was launched if the user selects our notification.Notif.contentintent =makemoodintent (Moodid); //in this sample, we'll use the same text for the ticker and the expanded notificationCharsequence Text =GetText (Textid); Notif.tickertext=text; //The icon for the status barNotif.icon =Moodid; //Our Custom Viewremoteviews Contentview = new  remoteviews (Getpackagename (), R.layout.status_bar_balloon); Contentview.settextviewtext (r.id.text, text); Contentview.setimageviewresource (R.id.icon, Moodid); Notif.contentview = Contentview; //we use a string ID of because is a unique number. We use it later to cancel the//Notificationmnotificationmanager.notify (mood_notifications, Notif); }

To distinguish it from the default status Bar layout, we are adding a imageview to the/res/status_bar_balloon.xml: An icon is displayed in the left and right, and the text is 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 default sounds, vibrations, or both:

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

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

"Sailing plan 026" 2015 sail plan Android Apidemo The Devil step of the App->notification->status bar status bar displays a customized notification layout that saves sound, vibration

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.