毕业论文基于安卓的日记本软件开发内容摘要:

事件,因此考虑在独立的搜索界面中,采用 EditText 和 ListView 组合的方式完成对关键字的监听和搜索。 界面一览 图 56 搜索界面 关于界面设计 功能说明 用户点击 ActionBar 上的操作 按钮,选择菜单项关于,能够从主界面进入到关于界面。 在关于界面,用户能够查看本软件的相关信息,轻触实体返回键,即可回到主界面。 内部设计 App 的名称由 大号字体书写,这里可以通过设置相应的属性使字体变大: android:textAppearance=?android:attr/textAppearanceLarge 通常情况下,在 xml 的属性中键入多个空格只显示一个空格。 为使能够正常显示多个空格,这里可以通过切换输入法的设置,将半角输入改为全角输入。 在全角输入的状态下键入多个空格,使得一行文字中间能够显示多个空格。 界面一览 图 57 关于界面 实体类的设计 闪电笔记通过实体类来传递数据。 以下定义一个实体类,包含笔记的编号、内容、 时间三个字段,包含新建笔记、查看笔记和修改笔记时调用的构造函数,包含笔记对象用以返回字段值的三个函数。 public class Note { private String content。 // 内容 private String time。 // 时间 private int ids。 public Note(String con) { = con。 } // 新建笔记时用 public Note(String con, String time) { this(con)。 = time。 } // 修改笔记时用 public Note(int id, String con, String time) { = id。 = con。 = time。 } public int getIds() { return ids。 } public String getContent() { return content。 } public String getTime() { return time。 } } 数据访问层的设计 闪电笔记将通用的数据操作独立外包到 中,使得后期对数据的修改工作变得简单明了。 通过继承 ,闪电笔记在重写的 onCreate 方法中创建数据库。 create table mynote(ids integer PRIMARY KEY autoincrement,content text,create_time text,modify_time text) 在 中,闪电笔记定义了一系列方法用以实现按顺序获取笔记列表、获取笔记内容、修改笔记、插入笔记、删除笔记。 // 从数据库读取数据并存放到 Arraylist 按创建时间排列 默认 public ArrayListNote getArray_cr(String sql) { ArrayListNote array = new ArrayListNote()。 db = ()。 Cursor cursor = (sql, null)。 ()。 while (!()) { int id = ((ids))。 String content = ((content))。 String create_time = (cursor .getColumnIndex(create_time))。 Note note = new Note(id, content, create_time)。 (note)。 ()。 } ()。 return array。 } // 从数据库读取数据并存放到 Arraylist 按修改时间排列 public ArrayListNote getArray_mo() { ArrayListNote array = new ArrayListNote()。 db = ()。 Cursor cursor = ( select * from mynote order by modify_time desc, null)。 ()。 while (!()) { int id = ((ids))。 String content = ((content))。 String modify_time = (cursor .getColumnIndex(modify_time))。 Note note = new Note(id, content, modify_time)。 (note)。 ()。 } ()。 return array。 } // 用于 Modify_note 获取笔记 public Note getNote(int id) { db = ()。 Cursor cursor = (select content from mynote where ids=39。 + id + 39。 , null)。 ()。 String content = ((content))。 Note note = new Note(content)。 ()。 return note。 } // 用于 Modify_note 修改笔记 public void toUpdate(Note note) { db = ()。 (update mynote set content=39。 + () + 39。 ,modify_time=39。 + () + 39。 where ids=39。 + () + 39。 )。 ()。 } // 用于 New_note 插入笔记 public void toInsert(Note note) { db = ()。 (insert into mynote(content,create_time)values(39。 + () + 39。 ,39。 + () + 39。 ))。 ()。 } // 用于 MainActivity 删除笔记 public void toDelete(int ids) { db = ()。 (delete from mynote where ids= + ids + )。 ()。 } 适配器类的设计 闪电笔记定义了一个继承于 BaseAdapter 的 MyAdapter 类。 在 MyAdapter类中重写了 getCount、 getItem、 getItemId,以及 getView 方法。 其中 getCount方法用于 Arraylist 获取数据的长度,以计算出笔记列表 ListView 需要显示多少行数据, getItem 方法用于定位指定行, getItemId 方法 用于返回列表项 id,getView方法需要得到优化,配合使用 ViewHodler和 ConvertView使得 ListView在加载大量数据时能够保持流畅的滚动。 以下贴出重写后的 getView 方法: @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Autogenerated method stub ViewHolder vh。 if (convertView == null) { vh = new ViewHolder()。 convertView = (, null)。 = (TextView) ()。 = (TextView) ()。 (vh)。 } vh = (ViewHolder) ()。 ((position).getContent())。 ((position).getTime())。 return convertView。 } class ViewHolder { TextView tv1, tv2。 } 新建笔记功能的设计 在 MainActivity 中,通过监听新建笔记按钮的点击事件, 当按钮被点击时,执行监听。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。