<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      通知欄notification的使用

      其中在android的文檔中有關于這方面的介紹 具體為  Dev Guide 下的 User iNTERFACE 下的Notifications

      其中主要分3種:Toast Notification (Toast就不用說了 大家都知道) 然后是Status Bar Notification(通知欄消息)以及Dialog Notification 這里主要介紹的通知欄

      一共4個步驟 在文檔中都有說明 下面就直接上代碼了 具體的自己看文檔吧

      代碼包含直接發送一個通知,以及自定義notification

      兩個布局文件

      mian.xml

       1 <?xml version="1.0" encoding="utf-8"?>
       2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       3     android:layout_width="fill_parent"
       4     android:layout_height="fill_parent"
       5     android:orientation="vertical" >
       6 
       7     <TextView
       8         android:layout_width="fill_parent"
       9         android:layout_height="wrap_content"
      10         android:text="@string/hello" />
      11 
      12     <Button
      13         android:id="@+id/button1"
      14         android:layout_width="wrap_content"
      15         android:layout_height="wrap_content"
      16         android:onClick="click"
      17         android:text="顯示一個提示消息" />
      18     <Button
      19         android:id="@+id/button1"
      20         android:layout_width="wrap_content"
      21         android:layout_height="wrap_content"
      22         android:onClick="click2"
      23         android:text="顯示一個自定義的消息" />
      24 </LinearLayout>

      notification.xml

       1 <?xml version="1.0" encoding="utf-8"?>
       2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       3     android:id="@+id/layout"
       4     android:layout_width="fill_parent"
       5     android:layout_height="fill_parent"
       6     android:padding="10dp" >
       7 
       8     <ImageView
       9         android:id="@+id/image"
      10         android:layout_width="wrap_content"
      11         android:layout_height="fill_parent"
      12         android:layout_alignParentLeft="true"
      13         android:layout_marginRight="10dp"
      14         android:src="@drawable/ic_launcher" />
      15 
      16     <TextView
      17         android:id="@+id/title"
      18         android:layout_width="wrap_content"
      19         android:layout_height="wrap_content"
      20         android:layout_toRightOf="@id/image"
      21         android:text="我是自定義的標題" />
      22 
      23     <ProgressBar
      24         android:id="@+id/pb"
      25        
      26         android:layout_width="200dip"
      27         android:layout_height="wrap_content"
      28         android:layout_below="@id/title"
      29         android:layout_toRightOf="@id/image"
      30         android:progress="30"
      31         android:max="100" />
      32 
      33 
      34 </RelativeLayout>

      activity

       1 package cn.itcast.notify;
       2 
       3 import android.app.Activity;
       4 import android.app.Notification;
       5 import android.app.NotificationManager;
       6 import android.app.PendingIntent;
       7 import android.content.Intent;
       8 import android.os.Bundle;
       9 import android.view.View;
      10 import android.widget.RemoteViews;
      11 
      12 public class DemoActivity extends Activity {
      13     /** Called when the activity is first created. */
      14     @Override
      15     public void onCreate(Bundle savedInstanceState) {
      16         super.onCreate(savedInstanceState);
      17         setContentView(R.layout.main);
      18     }
      19     public  void  click(View view){
      20         //1.得到系統與notification相關的服務
      21         NotificationManager   nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
      22         
      23         //2.初始化 一個 notification的對象 ,讓notificationmanager顯示
      24         Notification notification = new Notification(R.drawable.notification, "我是notification", System.currentTimeMillis());
      25         
      26         //3.設置notification的具體的參數
      27         notification.flags = Notification.FLAG_AUTO_CANCEL; //標示當前的notification不會被清除掉
      28         // notification.sound 指定notification的聲音
      29         // notification.vibrate long[]{200,100,200}
      30         notification.icon = R.drawable.notification;
      31         Intent intent = new Intent(this,DemoActivity.class);
      32         PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      33         notification.setLatestEventInfo(this, "我是正文的標題", "我是具體的內容", contentIntent);
      34         
      35         //4.利用notification的管理器把notification顯示出來
      36         nm.notify(0, notification);
      37         //nm.cancel(id)
      38     }
      39     
      40     public  void  click2(View view){
      41         //1.得到系統與notification相關的服務
      42         NotificationManager   nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
      43         
      44         //2.初始化 一個 notification的對象 ,讓notificationmanager顯示
      45         Notification notification = new Notification(R.drawable.notification, "我是notification", System.currentTimeMillis());
      46         
      47         //3.創建一個remoteview的對象
      48         RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
      49         contentView.setTextViewText(R.id.title, "Custom notification");
      50         //contentView.setTextViewText(R.id.text, "This is a custom layout");
      51         contentView.setProgressBar(R.id.pb, 100, 30, true);
      52         notification.contentView = contentView;
      53         Intent notificationIntent = new Intent(this, DemoActivity.class);
      54         PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
      55         notification.contentIntent = contentIntent;
      56         
      57         //4.利用notification的管理器把notification顯示出來
      58         nm.notify(2, notification);
      59         //nm.cancel(id)
      60     }
      61 }
      基礎/day07/notification

       

      posted @ 2013-01-19 20:29  王世楨  閱讀(350)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产麻豆精品一区一区三区| 欧美亚洲另类自拍偷在线拍| 欧美福利电影A在线播放| 亚洲黄色一级片在线观看| 国产福利酱国产一区二区| 国产福利一区二区三区在线观看| 夜夜夜高潮夜夜爽夜夜爰爰| 国产精品一区二区国产馆| 欧美videosdesexo吹潮| 东北女人毛多水多牲交视频 | 鸡西市| 虎白女粉嫩尤物福利视频| 亚洲精品一区二区天堂| 国产精品理论片| 亚洲日本欧美日韩中文字幕| 国产精品亚洲А∨天堂免| 久久国产成人午夜av影院| 国产精品国产三级国产专业| 丁香五月婷激情综合第九色 | 四虎影视库国产精品一区| 国产精品一区二区久久精品 | 亚东县| 成熟妇女性成熟满足视频| 99精品视频在线观看婷婷| 人成午夜免费大片| 国外av片免费看一区二区三区| 色婷婷婷丁香亚洲综合| 精品国产免费一区二区三区香蕉| 日韩av熟女人妻一区二| 免费人成网上在线观看网址| 熟女一区| 亚洲一区二区三区激情视频| 国产a在视频线精品视频下载 | 中文字幕av一区二区| 国产成人高清精品免费软件| 国产99视频精品免视看9| 99久久婷婷国产综合精品青草漫画| 久久99九九精品久久久久蜜桃| 色欲色香天天天综合网站免费| 亚洲色最新高清AV网站| 亚洲一区二区三午夜福利|