Android中NotePad学习

本文介绍了Notepad应用的基本功能及额外特色,包括时间戳显示、标题搜索、背景颜色个性化设置和文件导出等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NotePad

1.Notepad基本要求实现

1.1 获取Note创建时间,添加时间戳

获取Note创建时的系统时间(最终修改时间),并对时间的显示格式进行统一化要求,以列表的形式将Note的标题,图标和所获取的创建时间显示出来,
代码:

添加显示时间的TextView
    <TextView
        android:id="@+id/text1_time"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:paddingLeft="5dip"
        android:textColor="@color/colorBlack"/>

效果如下图:
main

1.2 NotePad搜索功能实现

从数据库中获取搜索结果,实现Note的标题搜索功能,
代码:

<item
    android:id="@+id/menu_search"
    android:title="@string/menu_search"
    android:icon="@android:drawable/ic_search_category_default"
    android:showAsAction="always">
</item>

效果如下:
search

2.Notepad额外功能实现

2.1 背景颜色变更

笔记背景颜色选择功能,使用自定义Dialog,在自定义Dialog中展示不同的颜色,并对展示的颜色进行设置ClickListener,当受到某种颜色点击响应后,背景颜色将会改变成所选择的笔记的颜色,背景颜色将会以SharesdPreferenced的方式进行保存。再次进入是会显示上次保存的背景色,使用户可以选择自己喜欢的风格来编辑Note。
代码:

//读取颜色数据
int x = mCursor.getInt(mCursor.getColumnIndex(NotePad.Notes.COLUMN_NAME_BACK_COLOR));
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.Gray_COLOR:
mText.setBackgroundColor(Color.rgb(165, 202, 237));
break;
case NotePad.Notes.Red_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;
}

效果截图:
gary red

2.2 Note输出功能

添加了输出文件的功能,可以将Note文件提取出来,效果展示:
这里写图片描述

到此结束~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值