如何将其变成两行,像下面这样:
提示
待跟进:9
未处理咨询:11
我传递了一个字符串值"待跟进:" + 所有跟进 + "\n" + "未处理咨询:" + 未处理咨询数量但没有显示成两行。
我使用的是android:minSdkVersion="7"
如何将其变成两行,像下面这样:
提示
待跟进:9
未处理咨询:11
我传递了一个字符串值"待跟进:" + 所有跟进 + "\n" + "未处理咨询:" + 未处理咨询数量但没有显示成两行。
我使用的是android:minSdkVersion="7"
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
Notification notification = builder.setContentIntent(contentIntent)
.setSmallIcon(icon).setTicker(appname).setWhen(0)
.setAutoCancel(true).setContentTitle(appname)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setContentText(message).build();
notificationManager.notify(0, notification);
也可以查看这个链接:通知扩展
祝您好运。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_notification"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<ImageView
android:id="@+id/notifiation_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/notification_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/notification_image"
android:layout_alignTop="@+id/notification_image"
/>
<TextView
android:id="@+id/notification_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/notification_image"
android:layout_below="@+id/notification_title"
/>
<TextView
android:id="@+id/notification_text_second_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/notification_image"
android:layout_below="@+id/notification_text"
/>
</RelativeLayout>
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setImageViewResource(R.id.notification_image, R.drawable.notification_image);
contentView.setTextViewText(R.id.notification_title, "My custom notification title");
contentView.setTextViewText(R.id.notification_text, "My custom notification text");
contentView.setTextViewText(R.id.notification_text_second_line, "My custom notification text second line");
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
Notification notification = builder
.setAutoCancel(true)
.setContent(contentView).build();
notificationManager.notify(0, notification);