主页

android使用Notify的一些笔记

首先一个很重要的一点,google在Android8以后加入了通知渠道功能,可以方便用户更好的管控通知类型。 带NotificationChannel的使用方法如下 //拿到NotificationManager对象,因为是在fragment中写的需要getContext, //拿到的对象需要强转成NotificationManager mNotificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); //创建通知渠道对象 1:通知id ...

阅读更多

SharedPreference

SharedPreference 写入 //可以创建一个新的SharedPreference来对储存的文件进行操作 SharedPreferences sp=context.getSharedPreferences("名称", Context.MODE_PRIVATE); //像SharedPreference中写入数据需要使用Editor SharedPreference.Editor editor = sp.edit(); //类似键值对 editor.putString("name", "string"); editor.putInt("age", 0); editor.putBoolean("read", true); //editor.apply(); editor.co...

阅读更多

Adapter的使用

Adapter的使用 适配器在Android编程中经常用到,我记录以下我学习BaseAdapter的过程 BaseAdapter 创建三个java类,一个是主要的活动类,一个是数据类,一个是适配器类 数据类中需要填入所需的变量 package com.phc.a1801_penghaicen_listview; /** * @author PengHaiChen */ //该类代表人员信息 public class Person { int image; String name; String sex; String class_; String classRome; public voi...

阅读更多

view通过sqlite进行数据填充

view通过sqlite进行数据填充 这次的项目主要是有适配器和数据库和listview操作。 项目中需要注意的地方有listview的长按操作,不能与点击操作搞混,还有上下文菜单的重写需要写在主方法的外边,如果listview的 item中有butoon,可能会覆盖点击操作,这个需要注意 充分运用dialog界面来进行信息收集 源码界面 主界面 package com.phc.a2020_03_22; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; imp...

阅读更多