2013-08-14 1 views
-1

이 이미지에서 알 수 있듯이 나는 빨간색 원 안에있는 것을 만들고 싶습니다. 알림 표시 줄에 텍스트를 만들려면 어떻게해야합니까? 이것은 이미지 :이 내 알림알림 표시 줄에 텍스트를 만들려면 어떻게해야합니까?

notificationBuilder = new NotificationCompat.Builder(context); 

       notificationBuilder.setOngoing(true); 
       notificationBuilder.setContentTitle("Battery Stats Informations"); 
       notificationBuilder.setContentText("Carica residua: " +level+"%" + " " + "Temperatura: " +temperature+ "°C"); 
       notificationBuilder.setTicker("Battery level " +level+ "%"); 
       notificationBuilder.setWhen(System.currentTimeMillis()); 
       notificationBuilder.setSmallIcon(R.drawable.icon_small_not).setWhen(System.currentTimeMillis()); 
       Intent notificationIntent = new Intent(context, MainActivity.class); 
       PendingIntent contentIntent = PendingIntent.getBroadcast(context, 0, notificationIntent, 0); 
       notificationBuilder.setContentIntent(contentIntent); 

       notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); 

       Notification not=notificationBuilder.build(); 

       mNotificationManager.notify(SIMPLE_NOTIFICATION_ID,not); 

감사

입니다 http://tinypic.com/view.php?pic=23hu5xd&s=6

답변

0

유무 N 아이콘, 각기 다른 "텍스트"를 표시하고, Notification.Builder에서 해당 아이콘을 사용하려면 하나 setSmallIcon() 전화.

IOW, "보는 사람이" "숫자가있는 이미지"보다 "텍스트"가 적습니다.

+0

다음과 같이하면됩니다. if (level = 100) {notificationBuilder.setSmallIcon (R.drawable.icon_small_not)} if (level <= 90) {notificationBuilder.setSmallIcon (R.drawable.icon_small_90)}' 등 등? –

+0

@David_D : 두 번째 매개 변수로 'level'을 사용하는'setSmallIcon()'의 두 개의 매개 변수 버전을 사용하고 그것들을'LevelListDrawable'으로 합치거나 합치십시오. – CommonsWare

+0

게시 방법은 3 분 전입니다.하지만 파란색 동그라미에있는 이미지의 이름은 무엇입니까? –