zoukankan      html  css  js  c++  java
  • 自定义通知栏

                    //实例化一个notification 
                     Notification notification = new Notification(R.drawable.ic_launcher, "tick", System.currentTimeMillis());
                     
                     //不能手动清理
                     notification.flags= Notification.FLAG_NO_CLEAR;
                     //添加音乐
                    notification.sound = Uri.parse("/sdcard/haha.mp3"); 
                    //将使用默认的声音来提醒用户  
                    notification.defaults = Notification.DEFAULT_SOUND;  
                    
                     //设置用户点击notification的动作 
                     // pendingIntent 延期的意图 
                     Intent intent = new Intent(this,SelfnotifitionActivity.class);
                     PendingIntent pendingIntent  = PendingIntent.getActivity(this, 0, intent, 0);
                     notification.contentIntent = pendingIntent;
                    
                     //自定义界面 
                     RemoteViews rv = new RemoteViews(getPackageName(), R.layout.notification);
                     rv.setTextViewText(R.id.text, "我是自定义的 notification");
                     notification.contentView = rv;
                     
                     //把定义的notification 传递给 notificationmanager 
                     NotificationManager notificationManager=  (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
                     notificationManager.notify(3, notification);
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:orientation="horizontal">
    
        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <ImageView
            android:id="@+id/image2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
            <ImageView
            android:id="@+id/image3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
                <ImageView
            android:id="@+id/image4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"/>
        <TextView
            android:id="@+id/text"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"      />
    
    </LinearLayout>
  • 相关阅读:
    <form:select>的使用
    存储过程-删除、新建索引
    java 反射常用总结
    java判断是否是数字
    jquery遍历数组添加行删除行
    oracle常用sql
    cxf (zhuan)
    linux 常用命令--个人小结一
    java发送邮件
    socket和webservice特点
  • 原文地址:https://www.cnblogs.com/clarence/p/3573132.html
Copyright © 2011-2022 走看看