簡體   English   中英

Notification.BigTextStyle沒有出現

[英]Notification.BigTextStyle not appearing

所以我正在學習使用BigTextStyle在xamarin android中進行通知。 由於某種原因,每當我運行代碼時,bigText和SetSummaryText都不會出現在通知中。 有人知道為什么嗎? 我的代碼如下:

     protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
         SetContentView (Resource.Layout.Main);
        Notification.Builder builder = new Notification.Builder(this)
            .SetContentTitle("Big Text")
            .SetSmallIcon(Resource.Drawable.Icon);


        Notification.BigTextStyle textStyle = new Notification.BigTextStyle();

        string longTextMessage = "I went up on one pair of stairs.";
        longTextMessage += " / Just like me. ";

        textStyle.BigText(longTextMessage);
        textStyle.SetSummaryText("The summary text goes here. ");
        builder.SetStyle(textStyle);
        Notification notification = builder.Build();


        NotificationManager notificationManager =
            GetSystemService(Context.NotificationService) as NotificationManager;

        const int notificationId = 0;
        notificationManager.Notify(notificationId, notification);
    }

在此處輸入圖片說明

var notification = new Notification.Builder(Application.Context)
    .SetSmallIcon(Resource.Mipmap.Icon)
    .SetLargeIcon(BitmapFactory.DecodeResource(Application.Context.Resources, Resource.Mipmap.Icon))
    .SetAutoCancel(true)
    .SetStyle(new Notification
              .BigTextStyle()
              .SetSummaryText("Summary Text")
              .SetBigContentTitle("Content Title")
              .BigText("Big Text Area")
             )
    .Build();
var notificationManager = (NotificationManager)Application.Context.GetSystemService(Context.NotificationService);
notificationManager.Notify(1, notification);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM