android 记事本demo_Android 简单记事本

写在前面

课程作业需要,于是忙活好几天抄了一个简单的记事本,使用已学内容包括Android UI布局,Activity的跳转,SQLite数据库。

开发环境:Android Studio

目录

一.界面预览

主界面

编辑界面

长按删除

二.基本实现

布局实现代码

初始界面功能,最上方标题下为用户创建的各条记录,点击进行修改,长按删除,最下方有添加笔记按钮进行笔记的增加操作。实现的布局文件有初始界面activity_main.xml(里面包含可以以列表的形式展示数据内容的ListView控件)、note_item(ListView对应的item布局,以显示每个条目信息)、note_editor(新建文本编辑界面)、activity_show(文本修改界面)

activity_main.xml

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#eaeaea"

android:orientation="vertical"

tools:context=".MainActivity" >

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Notepad"

android:textSize="20sp"

android:textStyle="bold"

android:background="#efdede"

android:paddingTop="10dp"

android:paddingBottom="5dp"

android:paddingLeft="10dp"

android:gravity="left">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#eaeaea"

android:layout_weight="1">

android:id="@+id/lv_note"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="5dp">

android:id="@+id/btn_add"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:gravity="center"

android:layout_marginBottom="10dp"

android:textSize="20sp"

android:text="添加笔记"/>

note_item.xml

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:id="@+id/tv_title"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginLeft="10dp"

android:lines="1"

android:text=""

android:textStyle="bold"

android:textAppearance="?android:attr/textAppearanceLarge"/>

android:id="@+id/tv_content"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginLeft="10dp"

android:lines="1"/>

android:id="@+id/tv_time"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginLeft="10dp"

android:text="" />

note_editor.xml

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#eaeaea"

android:orientation="vertical">

android:id="@+id/et_title"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:ems="10"

android:hint="请输入标题">

android:id="@+id/edit_time"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#d7d5d5"

android:gravity="right"

android:textSize="10sp"/>

android:id="@+id/et_content"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_weight="1"

android:hint="请输入内容"

android:gravity="left"/>

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:gravity="center">

android:id="@+id/btn_save"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:layout_marginBottom="10dp"

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值