我试图从内容视图中隐藏smallIcon,而不是从状态栏隐藏。 首先,我试着通过编写以下代码来隐藏它:
.setSmallIcon(android.R.color.transparent)
但状态栏中也看不到小图标。
然后我尝试了:
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interactivity;
public class DisableDoubleClickBehavior : Behavior<Button>
{
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.PreviewMouseDoubleClick += AssociatedObjectOnPreviewMouseDoubleClick;
}
private void AssociatedObjectOnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs)
{
mouseButtonEventArgs.Handled = true;
}
protected override void OnDetaching()
{
AssociatedObject.PreviewMouseDoubleClick -= AssociatedObjectOnPreviewMouseDoubleClick;
base.OnDetaching();
}
}
但它没有用。请指导我。提前谢谢。
答案 0 :(得分:0)
NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(getNotificationIcon())
.setContentTitle(getResources().getString(R.string.app_name))
.setWhen(System.currentTimeMillis())
.setContentText("New Message");
//get custom layout
RemoteViews notificationView = new RemoteViews(
getPackageName(),
R.layout.new_notification_card_layout
);
notificationView.setImageViewResource(R.id.notification_image, ResourceId);
notificationView.setTextViewText(R.id.title, title);
builder.setCustomBigContentView(notificationView);
public int getNotificationIcon() {
boolean useWhiteIcon = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.notification : R.drawable.notification_teal;
}