Squ*_*onk 5 android android-layout
在我的HTC手机上,用于通知的RemoteView如下图所示......

我想在我的应用程序中使用相同的布局(图像,粗体文本和小文本)进行通知,但是如果它是一个股票Android布局,我就无法解决.我已经创建了自己的布局,但它并不完全相同,如果可能的话,我想坚持使用'标准'.
使用eclipse我尝试输入android.R.layout.以查看建议是什么,但我看不到任何具有建议通知布局的名称.
它是一个股票Android布局?如果是这样,我该如何访问它?
它是标准的Android通知布局,您无需创建自己的自定义布局.只需使用现有的通知API来设置drawable,title和text.下面是一个使用NotificationCompat.Builder兼容性库的示例:
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());
Run Code Online (Sandbox Code Playgroud)
和使用Notification类相同:
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());
Run Code Online (Sandbox Code Playgroud)