Android Notification下拉样式
来源:互联网 发布:淘宝上店铺介绍怎么写 编辑:程序博客网 时间:2024/05/21 21:03
在android中接受通知,对通知的样式进行设置
public void notifyUser(int id, String title, String content, String tickerText) {// 获取系统的状态类通知notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);n = new Notification(R.drawable.icon, tickerText, System.currentTimeMillis());Intent intent = new Intent(context, CordovaApp.class);PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);n.contentIntent = pi;// 上下文、标题、内容、点击后出发的意图过滤器n.setLatestEventInfo(context, title, content, pi);n.defaults = Notification.DEFAULT_ALL; // 通知声音n.flags |= Notification.FLAG_SHOW_LIGHTS;n.flags |= Notification.FLAG_AUTO_CANCEL; // 点击后自动在状态栏消失n.icon = R.drawable.icon;n.when = System.currentTimeMillis();n.tickerText = tickerText;// 设置通知下来时候的样式// RemoteViews contentView=new// RemoteViews(getPackageName(),R.layout.pullnotice);// contentView.setImageViewResource(R.id.pullnoti,R.drawable.icon);// contentView.setTextViewText(R.id.text,content);// n.contentView=contentView;// 发送通知notificationManager.notify(id, n);}
n.icon = R.drawable.icon;
设置的是接收到消息的时候的图片
<pre name="code" class="java">n = new Notification(R.drawable.icon, tickerText, System.currentTimeMillis());这里的R.drawable.icon是通知下拉时候的图标,
<span style="font-family: Arial, Helvetica, sans-serif;"></span>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><pre name="code" class="java">// RemoteViews contentView=new// RemoteViews(getPackageName(),R.layout.pullnotice);// contentView.setImageViewResource(R.id.pullnoti,R.drawable.icon);// contentView.setTextViewText(R.id.text,content);// n.contentView=contentView;
这也是通知下拉时候的样式,这个是自定义的一个样式,可以在xml中定义好样式,<span style="font-family: Arial, Helvetica, sans-serif;">R.id.pullnoti是</span><span style="font-family: Arial, Helvetica, sans-serif;">R.layout.pullnotice当中的ImageView</span>
<span style="font-family: Arial, Helvetica, sans-serif;"></span><pre name="code" class="java">R.id.text是<span style="font-family: Arial, Helvetica, sans-serif;">R.layout.pullnotice当中的一个TextView</span>
0 0
- Android Notification下拉样式
- Android Notification 样式!
- Android Notification 样式!
- Android Notification自定义样式
- Android Notification常见样式总结
- Android Notification常见样式总结
- Android Notification常见样式总结
- Android Notification常见样式总结
- Android Notification常见样式总结
- Android Notification常见样式总结
- Android Notification常见样式总结
- Android Notification常见样式总结
- Notification样式
- android自定义Spinner下拉列表框样式
- Android Spinner 下拉样式 拒绝弹出
- Android-设置PullToRefresh下拉刷新样式
- Android-设置PullToRefresh下拉刷新样式
- Android中自定义下拉样式Spinner
- Atitit.网页爬虫的架构总结
- 【BST】把搜索二叉树转化成双链表
- 【深入浅出IOS开发】彩票-NavigationController
- 主機板 BIOS 嗶聲判讀詳解
- 对所给的斜率场求解方程,并将所给程序进行注释。
- Android Notification下拉样式
- SpringMVC-Day5
- 三十、纯虚函数、抽象类、多态、简单工厂模式
- ip地址与域名的关联
- 简易android手电筒app
- miscdevice混杂设备驱动
- php进行数据备份与还原
- 自定义View实现环形SeekBar
- java 中 ReentrantReadWriteLock的读锁和写锁的使用