2012-05-09 1 views
5

...안드로이드 알림 (RemoteView) 레이아웃입니까? 내 HTC 전화 통지의 리모트 뷰 아래 이미지처럼 보이는에

enter image description here

난에 알림에 대해 동일한 레이아웃 (이미지, 굵은 텍스트 및 작은 텍스트)를 사용하고 싶습니다 내 앱이지만 Android Android 레이아웃인지 여부는 알 수 없습니다. 내 레이아웃을 만들었지 만 꽤 똑같지는 않으며 가능하면 '표준'을 고수하고 싶습니다.

일식을 사용하여 android.R.layout.에 입력을 시도했지만 제안 사항은 무엇인지 알려주려고했지만 알림 레이아웃을 제안하는 이름이 보이지 않습니다.

안드로이드 레이아웃입니까? 그렇다면 어떻게 접근합니까?

답변

5

표준 Android 알림 레이아웃이므로 맞춤 레이아웃을 만들 필요가 없습니다. 기존 알림 API를 사용하여 드로어 블, 제목 및 텍스트를 설정하십시오.

Notification notification = new Notification(R.drawable.notification_icon, getText(R.string.notification_ticker), System.currentTimeMillis()); 

Intent notificationIntent = new Intent(this, ActivityHome.class); 
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); 

notification.setLatestEventInfo(this, getString(R.string.notification_title), getText(R.string.notification_text), pendingIntent); 

mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification()); 
: Notification 클래스를 사용하여

Intent notificationIntent = new Intent(this, ActivityHome.class); 
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); 

NotificationCompat.Builder builder = new NotificationCompat.Builder(this); 
builder.setContentIntent(pendingIntent) 
     .setWhen(System.currentTimeMillis()) 
     .setTicker(getText(R.string.notification_ticker)) 
     .setSmallIcon(R.drawable.notification_icon) 
     .setContentTitle(getText(R.string.notification_title)) 
     .setContentText(getText(R.string.notification_text)); 

mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification()); 

그리고 같은 : 다음 호환성 라이브러리에서 NotificationCompat.Builder를 사용하여 예입니다

관련 문제