如何在两行中创建
ALERT
待定后续行动:9
Enquery没有参加过一次:11
我传递字符串值"待定后续跟进:" + all_follow_ups +" \ n" +" Enquery没有参加过一次:" + noOfEnquiry 但没有显示在两行中。
我正在使用 android:minSdkVersion =" 7"
答案 0 :(得分:2)
在您的代码中添加:
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);
同时检查:Notification expand
希望这有帮助。
答案 1 :(得分:1)
你可以使用RemoteViews。
在custom_notification.xml
<?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);