-
使用 NotificationManager 顯示或取消通知 1. 設置全局變量 NotificationManager manager; // 通知管理類 int notification_ID; // 通知的ID號 2. 在 onCreate()方法中初始化 manager: manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 注意:NotificationManager的初始化:因為NotificationManager是系統服務,所以需要通過getSystemService()來獲取實例。 3. 調用方法(分別在不同的點擊事件中調用) manager.notify(notification_ID,notification); //顯示通知,其中notification是我們上節課構造好的通知。 manager.cancel(notification_ID); // 取消通知 ------------- 摘自評論區: 找到方法了調用代碼 builder.setAutoCancel(true);//通知消息會在被點擊后自動消失 OK了查看全部
-
哇 通知欄 builder.setDefaults(Notification.DEFAULT_ALL);//設置聲音 燈 震動查看全部
-
自定義對話框 自定義的對話框的布局為 R.layout.dialog_layout。 設置一個按鈕觸發該點擊事件(設置屬性 android:onClick="doClick7") 在 Activity 中編寫如下代碼: public void doClick7(View v){ LayoutInflater inflater = LayoutInflater.from(this); View dialog_view = inflater.inflate(R.layout.dialog_layout,null); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(dialog_view); AlertDialog dialog = builder.create(); dialog.show(); } ----------- 摘自評論區: 自定義的Dialog的View 里面的控件同樣可以用findViewById 的方式。就是View.findViewById(R.id.xxx);查看全部
-
一堆方法,不要記,用心感受查看全部
-
自定義Toast 先定義一個布局,然后用Toast把布局顯示出來查看全部
-
帶有圖片的Toast,很厲害查看全部
-
Log日志級別 E>W>I>D>V查看全部
-
相互補充,相互彌補查看全部
-
f6 逐行追蹤 f5 進入方法 f7 跳出方法 f8 下一個斷點或是結束Debug查看全部
-
AlertDialog常用方法查看全部
-
toast顯示圖片查看全部
-
Toast常用方法查看全部
-
debug調試程序的步驟方法查看全部
-
ContentMenu創建方法查看全部
-
創建菜單查看全部
舉報
0/150
提交
取消