基于NotePad应用做功能扩展

2023-05-16

#写在前面,解决图片不能查看问题

因为有 墙 的存在,DNS污染了,存在不能查看GitHub上图片问题

 配置hosts文件,直接指向github的服务器。用ipaddress查一下GitHub: Where the world builds software · GitHub 的ip

 hosts文件win10目录:C:\Windows\System32\drivers\etc

 在文件尾部添加:

185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
185.199.108.133 githubusercontent.com
185.199.109.133 githubusercontent.com
185.199.110.133 githubusercontent.com
185.199.111.133 githubusercontent.com

 保存,关闭,重新加载网页即可

# NotePad
This is an AndroidStudio rebuild of google SDK sample NotePad
# 新增类,修改类(部分代码展示)

• MyCursorAdapter.java

public void bindView(View view, Context context, Cursor cursor){
        super.bindView(view, context, cursor);
        //从数据库中读取的cursor中获取笔记列表对应的颜色数据,并设置笔记颜色
        int x =               
       cursor.getInt(cursor.getColumnIndex(NotePad.Notes.COLUMN_NAME_BACK_COLOR));
        switch (x){
            case NotePad.Notes.DEFAULT_COLOR:
                view.setBackgroundColor(Color.rgb(255, 255, 255));
                break;
            case NotePad.Notes.YELLOW_COLOR:
                view.setBackgroundColor(Color.rgb(247, 216, 133));
                break;
            case NotePad.Notes.BLUE_COLOR:
                view.setBackgroundColor(Color.rgb(165, 202, 237));
                break;
            case NotePad.Notes.GREEN_COLOR:
                view.setBackgroundColor(Color.rgb(161, 214, 174));
                break;
            case NotePad.Notes.RED_COLOR:
                view.setBackgroundColor(Color.rgb(244, 149, 133));
                break;
            default:
                view.setBackgroundColor(Color.rgb(255, 255, 255));
                break;
        }
    }

• NoteSearch.java

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.note_search_list);
        Intent intent = getIntent();
        if (intent.getData() == null) {
            intent.setData(NotePad.Notes.CONTENT_URI);
        }
        SearchView searchview = (SearchView)findViewById(R.id.search_view);
        searchview.setOnQueryTextListener(NoteSearch.this);  //为查询文本框注册监听器
    }

• OutputText.java

private void write()
    {
        try
        {
            // 如果手机插入了SD卡,而且应用程序具有访问SD的权限
            if (Environment.getExternalStorageState().equals(
                    Environment.MEDIA_MOUNTED)) {
                // 获取SD卡的目录
                File sdCardDir = Environment.getExternalStorageDirectory();
                //创建文件目录
                File targetFile = new File(sdCardDir.getCanonicalPath() + "/" + mName.getText() + ".txt");
                //写文件
                PrintWriter ps = new PrintWriter(new OutputStreamWriter(new FileOutputStream(targetFile), "UTF-8"));
                ps.println(TITLE);
                ps.println(NOTE);
                ps.println("创建时间:" + CREATE_DATE);
                ps.println("最后一次修改时间:" + MODIFICATION_DATE);
                ps.close();
                Toast.makeText(this, "保存成功,保存位置:" + sdCardDir.getCanonicalPath() + "/" + mName.getText() + ".txt", Toast.LENGTH_LONG).show();
            }
        }

• NoteEditor.java
    设置颜色
    

switch (x){
                case NotePad.Notes.DEFAULT_COLOR:
                    mText.setBackgroundColor(Color.rgb(255, 255, 255));
                    break;
                case NotePad.Notes.YELLOW_COLOR:
                    mText.setBackgroundColor(Color.rgb(247, 216, 133));
                    break;
                case NotePad.Notes.BLUE_COLOR:
                    mText.setBackgroundColor(Color.rgb(165, 202, 237));
                    break;
                case NotePad.Notes.GREEN_COLOR:
                    mText.setBackgroundColor(Color.rgb(161, 214, 174));
                    break;
                case NotePad.Notes.RED_COLOR:
                    mText.setBackgroundColor(Color.rgb(244, 149, 133));
                    break;
                default:
                    mText.setBackgroundColor(Color.rgb(255, 255, 255));
                    break;
            }

• NotePad.java
    设置颜色

  public static final int DEFAULT_COLOR = 0; //白
        public static final int YELLOW_COLOR = 1;//黄
        public static final int BLUE_COLOR = 2;//蓝
        public static final int GREEN_COLOR = 3;//绿
        public static final int RED_COLOR = 4;//红
        


• NotesList.java
    设置搜索,排序    

    @Override
        public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_add:
          /*
           * Launches a new Activity using an Intent. The intent filter for the Activity
           * has to have action ACTION_INSERT. No category is set, so DEFAULT is assumed.
           * In effect, this starts the NoteEditor Activity in NotePad.
           */
                startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData()));
                return true;
            case R.id.menu_paste:
          /*
           * Launches a new Activity using an Intent. The intent filter for the Activity
           * has to have action ACTION_PASTE. No category is set, so DEFAULT is assumed.
           * In effect, this starts the NoteEditor Activity in NotePad.
           */
                startActivity(new Intent(Intent.ACTION_PASTE, getIntent().getData()));
                return true;
            //添加搜素
            case R.id.menu_search:
                Intent intent = new Intent();
                intent.setClass(NotesList.this,NoteSearch.class);
                NotesList.this.startActivity(intent);
                return true;

            //创建时间排序
            case R.id.menu_sort1:
                cursor = managedQuery(
                        getIntent().getData(),            // Use the default content URI for the provider.
                        PROJECTION,                       // Return the note ID and title for each note. and modifcation date
                        null,                             // No where clause, return all records.
                        null,                             // No where clause, therefore no where column values.
                        NotePad.Notes._ID  // Use the default sort order.
                );
                adapter = new MyCursorAdapter(
                        this,
                        R.layout.noteslist_item,
                        cursor,
                        dataColumns,
                        viewIDs
                );
                setListAdapter(adapter);
                return true;

            //修改时间排序
            case R.id.menu_sort2:
                cursor = managedQuery(
                        getIntent().getData(),            // Use the default content URI for the provider.
                        PROJECTION,                       // Return the note ID and title for each note. and modifcation date
                        null,                             // No where clause, return all records.
                        null,                             // No where clause, therefore no where column values.
                        NotePad.Notes.DEFAULT_SORT_ORDER // Use the default sort order.
                );

                adapter = new MyCursorAdapter(
                        this,
                        R.layout.noteslist_item,
                        cursor,
                        dataColumns,
                        viewIDs
                );
                setListAdapter(adapter);
                return true;

            //颜色排序
            case R.id.menu_sort3:
                cursor = managedQuery(
                        getIntent().getData(),            // Use the default content URI for the provider.
                        PROJECTION,                       // Return the note ID and title for each note. and modifcation date
                        null,                             // No where clause, return all records.
                        null,                             // No where clause, therefore no where column values.
                        NotePad.Notes.COLUMN_NAME_BACK_COLOR // Use the default sort order.
                );
                adapter = new MyCursorAdapter(
                        this,
                        R.layout.noteslist_item,
                        cursor,
                        dataColumns,
                        viewIDs
                );
                setListAdapter(adapter);
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    }

# 新建布局,修改布局

• note_color.xml
  举例

<ImageButton
        android:id="@+id/color_white"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@color/colorWhite"
        android:onClick="white"/>

• note_srarch_list.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageButton
        android:id="@+id/color_white"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@color/colorWhite"
        android:onClick="white"/>

    <ImageButton
        android:id="@+id/color_yellow"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@color/colorYellow"
        android:onClick="yellow"/>

    <ImageButton
        android:id="@+id/color_blue"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@color/colorBlue"
        android:onClick="blue"/>

    <ImageButton
        android:id="@+id/color_green"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@color/colorGreen"
        android:onClick="green"/>

    <ImageButton
        android:id="@+id/color_red"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@color/colorRed"
        android:onClick="red"/>
    
</LinearLayout>

 • output_text.xml

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
    android:paddingBottom="3dip">

    <EditText android:id="@+id/output_name"
        android:maxLines="1"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="15dp"
        android:layout_width="wrap_content"
        android:ems="25"
        android:layout_height="wrap_content"
        android:autoText="true"
        android:capitalize="sentences"
        android:scrollHorizontally="true" />

    <Button android:id="@+id/output_ok"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:text="@string/output_ok"
        android:onClick="OutputOk" />

</LinearLayout>

   

• colors.xml

 
# 页面布局

# 基本要求:
• NoteList中显示条目增加时间戳显示

• 添加笔记查询功能(根据标题查询)
默认title为输入内容,可自行更改,但查询是按照title查询,若title与笔记内容则笔记内容便无法查询到

 

 

 

# 附加功能:
• UI美化
我的排版参考PPT中的UI美化,将功能按键安排在上方

 

• 更改记事本的背景
需要在笔记中设置,在笔记初始展示页以带背景颜色的横条表示

 

 

• 导出笔记

 

• 笔记排序
可以根据创建时间、修改时间和颜色进行排序

 

 

 

源码地址:GitHub - cqm123456/NotePad: my

作者:陈巧蔓
原文链接:https://blog.csdn.net/chen_qm/article/details/121875018

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

基于NotePad应用做功能扩展 的相关文章

  • 03--C#入门基础

    今天我们就开始正式进入C 的入门学习 xff0c 从最简单的基础开始切入 xff0c 总结内容都非常的细节 xff0c 但也没有全部概况进去 xff0c 大家可以根据自己情况选择查看 xff0c 如有错处 xff0c 欢迎指正 目录 VS中
  • 04--C#运算符

    这一篇详细的介绍了C 中的几种运算符 xff0c 算术运算符 赋值运算符 复合赋值运算符 关系运算符 逻辑运算符 一元运算符 二元运算符 赋值运算符 61 xff1a 表示赋值 xff0c 表示把等号右边的值 xff0c 赋值给等号左边的变
  • Excel对图片的组合以及选择

    今天介绍的是利用Excel对图片进行的一些简单处理的方法 xff0c 比如对图片的编辑以及组合 xff0c 以及对图片的选择 xff1a 对图片进行一些圈红标注 xff1a 插入 gt 形状 gt 选择一个矩形框 xff0c 圈主自己要注释
  • 02--C#Winform--控件大小随窗口大小改变等比例变化

    最近在做Winform相关的项目 xff0c 这就会涉及到如何将窗口里的控件大小随窗口的调整而改变大小 xff0c 一开始想要直接调整窗口以及控件的属性来达到效果 xff0c 比如 xff0c Anchor和Dock属性 xff0c 但是没
  • 05--C#流程控制

    前面讲到的都是顺序结构 xff0c 顺序结构的意思就是程序从main函数进入 xff0c 从上到下一行一行的执行 xff0c 不会落下任何一行 xff0c 这章的内容就会讲到流程控制相关的几个结构 xff1a 分支结构 选择结构 循环结构
  • 03--C#Winform--让你的button控件更漂亮

    最近做一个小的项目 xff0c 想要将部门的各种资料 各种辅助软件汇总一下 xff0c 需要使用到很多的button的控件 xff0c 然后效果是这样的 xff1a 额 这效果太难看了 xff0c 不符合小姐姐的审美 xff0c 就打算深入
  • java,验证码base64编码到json字符串出显数据一行一行的问题,关于base64编码函数解释

    因为在写项目图片验证码时遇到 xff1a 一个json解析错误 Error 在第1行发生解析错误 34 code 34 34 9j 4AAQSkZJRgABAgA 此处缺少 39 STRING 39 39 NUMBER 39 39 NULL
  • HCNA配置静态LACP模式链路聚合

    1 静态LACP模式 静态LACP模式是一种利用LACP协议进行聚合参数协商 确定活动接口和非活动接口的链路聚合方式 该模式下 xff0c 需手工创建Eth Trunk xff0c 手工加入Eth Trunk成员接口 xff0c 由LACP
  • 在vs中配置cuda环境

    问题 xff1a 在vs中配置cuda环境 1 xff1a 包含头文件路径 xff1a VC 43 43 Directories gt Include Directories C ProgramData NVIDIA Corporation
  • 屏蔽编译过程中的警告信息cmake、QT

    linux中配置cmake文件屏蔽警告 在 cmake 中添加add definitions w QT工程中屏蔽警告输出 在工程文件 pro 里面添加 DEFINES 43 61 QT NO WARNING OUTPUT QT NO DEB
  • wps浏览器插件(wps online) webwps

    LINUX 下 WPS 浏览器插件 本wps插件可以实现将wps嵌入linux系统浏览器中 xff08 在linux系统中 xff0c web 端使用wps xff09 xff0c 以实现在浏览器中 阅读 修改 上传 下载以及特殊的快捷操作
  • c/c++ trim

    use erase and find if to implement trim c c 43 43 trim 实现字符串两头空格删除 span class token macro property span class token dire
  • QT之删除指定目录下指定尾缀文件

    使用QT删除指定目录下指定尾缀的文件 use entryList span class token comment delete the files endswith ref dir name the dir to remove files
  • C语言实现MATLAB中的fir1函数(绝对一摸一样的系数矩阵)

    span class token macro property span class token directive hash span span class token directive keyword include span spa
  • C++语音识别

    visual c 43 43 创建Win32工程调用windows API 做语音识别 查找了很多资料 xff0c 但是很少用Win32的 xff0c 国外倒是有很多人用C 调用Windows API 做语音识别 很多结合语音识别与word
  • 傅里叶变换(二维离散傅里叶变换)

    离散二维傅里叶变换 一常用性质 xff1a 可分离性 周期性和共轭对称性 平移性 旋转性质 卷积与相关定理 xff1b xff08 1 xff09 可分离性 xff1a 二维离散傅里叶变换DFT可分离性的基本思想是DFT可分离为两次一维DF
  • windows10+vs2015+python3.5编译安装caffe-ssd

    第一步 xff1a 下载caffe ssd 此下载链接是针对windows的caffe ssd源 第二步 xff1a 下载编译工具Cmake xff0c 现在的Cmake版本已经很高了 xff0c 不过建议是使用 gt 61 3 4的版本
  • 人脸方向学习(四):Face Recognition-SphereFace解读

    整理的人脸系列学习经验 xff1a 包括人脸检测 人脸关键点检测 人脸优选 人脸对齐 人脸特征提取五个过程总结 xff0c 有需要的可以参考 xff0c 仅供学习 xff0c 请勿盗用 https blog csdn net TheDayI
  • CAS服务端搭建

    CAS服务端搭建 工具 jdk1 8 tomcat 8 5 50 注意要使用tomcat8版本以上的 cas overlay template 5 2 1 我这里用的是一个无侵入式的一套来设计cas xff0c 所谓的无侵入式就是你直接打成
  • 由于目标计算机积极拒绝,无法连接的原因

    做网络编程时 xff0c 经常碰到 由于目标计算机积极拒绝 xff0c 无法连接 出现这种情况都有哪些原因呢 xff1f 第一种情况就是要连接的电脑没有开机 xff0c 当然无法连接了 第二种情况 xff0c 就是电脑虽然打开了 xff0c

随机推荐

  • TurboVNC with LightDM+Xfce desktop preparation

    Below shows the script to prepare TurboVNC with LightDM Xfce deskt nbsp TIMESTAMP date Y m d H M S install pkgs yum y gr
  • 头文件为什么只声明而不定义,而类定义又可以在头文件中那

    一 xff0e 头文件为什么只声明而不定义 xff0c 而类定义又可以在头文件中那 xff1f xff1f xff1f 了解基本的概念 xff1a 编译单元 xff1a 对于c语言 xff0c 每一个 c文件就是一个编译单元 仅从编译而言
  • Linux系统中ubuntu,redhat,debain,centos,fedora,suse 区别

    主流的linux系统有 xff1a ubuntu redhat debain centos fedora suse等 redhat是为企业设计的 xff1b fedora是红帽的兄弟 xff0c 比它更新快 xff0c 但不一定稳定ubun
  • 网络编程面试题(2020最新版)

    Java面试总结 xff08 2021优化版 xff09 已发布在个人微信公众号 技术人成长之路 xff0c 优化版首先修正了读者反馈的部分答案存在的错误 xff0c 同时根据最新面试总结 xff0c 删除了低频问题 xff0c 添加了一些
  • 计算机网络 | 构造超网 | CIDR

    目录 一 无分类编址CIDR xff08 构造超网 xff09 1 为什么要使用CIDR 2 网络前缀 3 路由聚合和构成超网 4 CIDO的其他表示方法 5 总结 一 无分类编址CIDR xff08 构造超网 xff09 1 为什么要使用
  • zsh配置(装机自用)

    每次因为重置电脑或者买新电脑或者买服务器 xff0c 总要装zsh和oh my zsh xff0c 之前看的都是别人写好的 xff0c 然后要把好几篇固定常看的连在一起看 xff0c 很烦人 xff0c 干脆自己结合几篇写个自己的步骤 xf
  • 理解之 原型链

    JavaScript 的继承主要通过原型链来继承 继承的主要精髓就是 xff1a 让一个对象的实例等于另一个原型对象 即 span class hljs attribute Super prototype span 61 span clas
  • Docker 容器时间和系统时间存在误差解决方法

    问题描述 xff1a docker容器的时间和系统时间存在8小时误差 xff0c 容器使用UTC时区 xff0c 系统使用CST时区时间 原因分析及解决方法 创建容器的时候就应该使用 v etc localtime 容器名称或者id etc
  • 解决web项目发布新版本需要清除浏览器缓存的问题

    一 bug起因 最近做公司的项目 xff0c 对样式进行了修改后 xff0c 新版本上线 测试那边经常说 xff1a 修改的样式没有生效 xff0c 我都是让他们清下浏览器缓存试试 可是到了正式环境 xff0c 用户 xff08 也就是老总
  • Ubuntu16.04TLS 中终端(Terminal)无法打开的解决办法

    前几天把系统自带的python3 5升级到python3 6 5后就关闭了系统 xff0c 结果今天打开电脑发现终端怎么也打不开了 xff0c 于是从网上找了一些解决办法 xff0c 终于找到一和自己类似情况的解决办法终端无法打开的解决办法
  • Linux命令

    1 访问权限 1 读权限 xff08 r xff09 对文件而言 xff0c 具有读取文件内容的权限 xff1b 对目录来说 xff0c 具有浏览目录的权限 2 写权限 xff08 w xff09 对文件而言 xff0c 具有新增 修改文件
  • curl命令

    目录 一 最常用的curl命令 1 发送GET请求 2 发送POST请求 3 发送json格式请求 xff1a 二 curl命令语法与curl命令参数详解 1 curl命令语法 2 curl命令参数详解 三 Linux curl命令退出码
  • 如何解决IP地址发生冲突故障?

    我们之前发布了关于交换机如何解决IP地址冲突 xff1f 这里面是以实例的方式讲解了如何防止交换机冲突 xff0c 有一些朋友反映这个设置起来有些复杂 xff0c 有没有其它的一些方法呢 xff1f 其实是有的 xff0c 我们今天来看下
  • 运筹帷幄的“懒蚂蚁”

    每个公司都有这样一种人 xff1a 他们工作起来不慌不忙 xff0c 无论客观环境如何影响 xff0c 他们总有自己的节奏 xff0c 战术上看起来满是松弛感 xff0c 但战略上似乎又不是 xff0c 而且这类人 xff0c 也偏偏总能被
  • 最好的生活方式:存钱,运动,读书,早起

    想一想 xff0c 这是不是你的日常 xff1a 明知道跑步能健身 xff0c 却始终迈不开腿 xff1b 嘴上说存钱 xff0c 却还在疯狂购物 xff1b 阅读计划做了一堆 xff0c 却总是安慰自己 xff1a 明天再开始吧 xff1
  • 【业务测试】

    业务测试疑问 xff1a 你觉得业务测试就是点点点吗 xff1f 你觉得业务测试就是依据需求设计case并全部执行通过就OK了吗 xff1f 你觉得业务测试就是功能测试 43 兼容测试 43 性能测试 43 接口测试 43 自动化吗 xff
  • selenium之如何定位iframe中的元素

    今天想写个126邮箱自动化登录脚本 xff0c 由于id是动态的 xff0c name也获取不到 xff0c 最后通过查看页面发现是写在iframe中 xff0c 所以要先获取表单 xff0c 在获取表单中的元素 xff0c 代码如下 xf
  • 无法连接虚拟机网络的情况之---Vmnet8 Net网络连接方式

    最近一直在虚拟机win7系统完loadrunner 昨晚突然想连接linux系统 xff0c 但是发现链接不上之前搭建的集群主机 xff0c 在linux服务器也能ping通www baidu com 但是在宿主机secureCRT链接不到
  • select * from .... for update 使用

    今天看到同事在群里发for update的sql 初步了解下 xff01 解释 xff1a for update是在数据库中上锁用的 xff0c 可以为数据库中的行上一个排它锁 当一个事务的操作未完成时候 xff0c 其他事务可以读取但是不
  • 基于NotePad应用做功能扩展

    写在前面 xff0c 解决图片不能查看问题 因为有 墙 的存在 xff0c DNS污染了 xff0c 存在不能查看GitHub上图片问题 配置hosts文件 xff0c 直接指向github的服务器 用ipaddress查一下GitHub