- 浏览: 236434 次
- 性别:
- 来自: 内蒙古
文章分类
- 全部博客 (236)
- Android 功能实现 (31)
- sql数据库的学习 (8)
- Android 美化界面 (2)
- Android 优化 (1)
- Ruby on Rails 方面 (45)
- git 方面的学习 (1)
- ruby 编程的琢磨 (13)
- linux下工具软件 (13)
- 操作系统的学习 (40)
- 非技术 (13)
- 网站开发 (18)
- js 学习笔记 (19)
- css学习 (5)
- 回顾总结 (2)
- Delphi 学习 (2)
- C 语言学习笔记 (1)
- 数据结构 (1)
- node js 学习 (6)
- 设计模式 (2)
- mongdb 学习笔记 (0)
- 软件服务 (3)
- osx系统 (4)
- 搜索引擎 (1)
- 测试工具 (1)
- Aliyun (1)
- 前端JS (1)
- python学习 (0)
- iOS系统 (1)
- 分布式锁 (1)
- 开发工具 (0)
- java代码 (2)
- java (0)
最新评论
-
jiguanghover:
写的不错,收藏一下
Ubuntu下RVM, Ruby, rails安装详细 和 卸载 -
maoghj:
回顾总结(二) -
yun2223:
对楼主表示感谢
Android控件开发之Gallery3D效果 -
zw_lovec:
说清楚点吧 亲 加点注释
out of memory -
lzyfn123:
http://www.iteye.com/images/smi ...
ruby-string 字符串的学习
第一步:新建一个工程,命名为Notification;
第二步:新建一个布局文件(即自定义的notification的布局文件:custom_notification.xml,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android
"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:contentDescription="@string/Image" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
style="@style/NotificationTitle" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
android:layout_below="@id/title"
style="@style/NotificationText" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android
"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:contentDescription="@string/Image" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
style="@style/NotificationTitle" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
android:layout_below="@id/title"
style="@style/NotificationText" />
</RelativeLayout>
第三步:新建上面布局文件中引用到的styyes.xml文件,代码如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" />
<style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="NotificationText" parent="android:TextAppearance.StatusBar.EventContent" />
<style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />
</resources>
第四步:修改java源文件,代码如下:
public class CusNotificationActivity extends Activity {
private static final int CUSTOM_VIEW_ID = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Notification notification = new Notification();
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "Notification01";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setImageViewResource(R.id.image, R.drawable.notification_image);
contentView.setTextViewText(R.id.title, "Custom notification");
contentView.setTextViewText(R.id.text, "This is a custom layout");
notification.contentView = contentView;
Intent notificationIntent = new Intent(this, CusNotificationActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(CusNotificationActivity.this, 0, notificationIntent, 0);
notification.contentIntent = contentIntent;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(CUSTOM_VIEW_ID, notification);
}
}
public class CusNotificationActivity extends Activity {
private static final int CUSTOM_VIEW_ID = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Notification notification = new Notification();
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "Notification01";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification);
contentView.setImageViewResource(R.id.image, R.drawable.notification_image);
contentView.setTextViewText(R.id.title, "Custom notification");
contentView.setTextViewText(R.id.text, "This is a custom layout");
notification.contentView = contentView;
Intent notificationIntent = new Intent(this, CusNotificationActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(CusNotificationActivity.this, 0, notificationIntent, 0);
notification.contentIntent = contentIntent;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(CUSTOM_VIEW_ID, notification);
}
}
发表评论
-
Android里的音量调节
2013-04-01 13:37 1317步骤1:或许系统音量 ... -
Android Camera 方法分析
2012-03-29 10:52 3483Android Camera源码分析 android通 ... -
MyCameraActivity
2012-03-29 10:10 671package cn.fn; import android. ... -
MyCameraActivity
2012-04-01 13:27 868package cn.fn; import android. ... -
android AutoCompleteTextView+ SQLite
2012-03-21 13:33 1088android AutoCompleteTextView+ S ... -
android 异步回调加载网络图片
2012-03-20 11:50 914在做应用的时候很多时候都会去从网络加载图片,而且还要做各种各样 ... -
ProgressBar+AsyncTask 实现界面数据异步加载
2012-03-20 10:09 1597ProgressBar+AsyncTask 实现界面数据异步 ... -
Android 网络图片异步加载实例
2012-03-20 10:04 949Android 网络图片异步加载实例 ... -
解决java.lang.OutOfMemoryError
2012-03-19 15:53 1063解决java.lang.OutOfMemoryError ... -
android Text 删除线
2012-03-16 19:35 1144import android.app.Activit ... -
android Gallery 详解
2012-03-14 14:17 1499android Gallery 正文 ... -
Android的线程使用来更新UI----Thread、Handler、Looper、TimerTask,Task,AsynTask等
2012-03-14 11:43 1434Android的线程使用来更新UI----Thread、Han ... -
AsyncTask的使用
2012-03-14 10:59 785AsyncTask的使用 ... -
Android控件开发之Gallery3D效果
2012-03-13 14:38 2853Android控件开发之Gal ... -
android GridView
2012-03-08 10:28 901主类 import android.app.Activi ... -
ListView异步加载图片是非常实用的方法
2012-03-08 10:09 923ListView异步加载图片是非常实用的方法,凡是是要通过网络 ... -
复制assets下的数据库到SD卡
2012-03-07 10:56 1203首先使用sqliteadDev(一个windows下图形化sq ... -
Android异步加载图像小结
2012-03-06 16:46 588Android异步加载图像小结 (1)由于an ... -
AutoCompleteTextView
2012-03-05 14:53 1411AutoCompleteTextView ... -
android 动态加载List
2012-03-05 11:11 977main.xml <?xml ver ...
相关推荐
4.1创建自定义布局的notification 布局包含progressbar progressbar颜色可以变 自定义progressbar 布局中多个按钮可以点击 动态更新notification中的progressbar
本篇运用ImageView和TextView等对Notification进行自定义布局 同时这也是中国大学慕课移动终端应用开发的网课作业19,我会持续更新我的作业,如果有需要关注一下吧 说明 1.参考文章安卓仿网易云音乐通知栏控制音乐 2...
android notification的应用,自定义notification布局,发布notificaiton和取消notification。
主要为大家详细介绍了Notification消息通知,消息合并且显示条数,自定义消息通知内容布局,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
根据本讲学习内容,学会运用Notification,并对Notification进行自定义布局。 (1)创建一个模拟音乐播放的信息提示。 (2) 提交的作业包中含有应用程序运行效果截图。
主要利用了notification service 和receiver 实现了用户通知栏更新,失败了点击重新下载,下载好了点击自动安装,布局很丑,请根据自己项目的实际需求自行修改
Notification安卓手机通知栏的常见到,该demo包含系统默认样式通知,带有进入条的通知以及自定义样式的通知,能自定义要多炫自己就可以随心布局修改;具体请参考...
notification个使用,可自定义高度,布局
和博客得配套看http://blog.csdn.net/yangjianbo456/article/details/50478180 博客名:Notification通知栏在app更新时自定义布局与原生态的对比分析(自定义的布局会卡死!); 可以大家一起讨论,互相学习。
notification是一种出现在任务栏的提示,特别是在4.0以后notification改进了不少,本文内容都是基于4.0及4.1以后总结来的,详细介绍各种布局的Notification样式,实现音乐播放器、邮件通知等复杂的例子详细代码。
大布局notification是在android4.1以后才增加的,大布局notification与小布局notification只在‘7′部分有区别,其它部分都一致。大布局notification只有在所有notification的最上 面时才会显示大布局,其它情况...
可以设置一条通知,当然可以更新一条通知,我们通过在调用NotificationManager.notify(ID, notification)时所使用的ID来更新它。为了更新你之前发布的通知,你需要更新或者创建一个NotificationCompat.Builder对象,...
Notification安卓手机通知栏的常见到,该demo包含系统默认样式通知以及自定义样式的通知,能自定义要多炫自己就可以随心布局修改;具体请参考http://blog.csdn.net/daitu_liang/article/details/50246803
概述有3个主要组成部分: 本地通知(管理布局通知) 全局通知(管理浮动通知) 通知远程(管理状态栏通知) 和2个次要组件: 公告板(保存公告列表) 通知效果(管理铃声,振动等) 每个通知可以具有自己的布局和...
二、Notification的基本布局 元素组成: Icon/Photo:大图标 Tiltle/Name:标题 Message:内容消息 Timestamp:通知的时间,默认是系统发出的时间,也可以通过setWhen()来设置 secondary Icon小图标 三、...
JiNexus/Zend-Notification是扩展并利用Zend-Mail , Zend-View , Zend-Config , Zend-Servicemanager和Zend-Filter来生成和发送布局合理的电子邮件的组件。 该组件还使用Cerberus-Responsive作为示例基本电子...
代码如下:Notification n = new Notification(android.R.drawable.ic_menu_share, null, System.currentTimeMillis()); 参数:图标 ID,发送到状态栏瞬间的文字,当前时间 2.设置详细信息:标题、内容、int
安卓通知栏自定义布局提示(NotificationCompat.Builder)
Android状态栏提醒 ...而使用Notification就不会带来这些麻烦事,用户完全可以打完游戏再去看这条短信。所以在开发中应根据实际需求,选择合适的控件。 步骤: 一、添加布局对象 代码如下:<Buttonandroid:id=”@