Android记事本【1】
来源:互联网 发布:js array lastindexof 编辑:程序博客网 时间:2024/05/29 08:52
这个程序是developer.android.com里面的一个例子,网上有源代码。姑且拿来做个练习,抛砖引玉。
假设您已经有一点Android开发的基础知识,并且配置好开发环境。
一、首先让我们对本次开发做个简单的总体设计:
界面及交互流程:
SQLite数据表设计:
代码结构设计:
›src/notepad.example.notepad/
›NotepadActivity.java
›NoteEditActivity.java
›NotesDbAdapter.java
›res/drawable/icon.png
›res/layout/
›notes_list.xml
›notes_row.xml
›note_edit.xml
二、先有个入口界面:
1.新建Android工程,程序命名为:Notepad,工程名为:Notepad,Package名为:com.example.notepad。Build SDK选Android 2.2, Minimum Required SDK 选2.2。一路”NEXT”,最后Activity名为:NotepadActivity,布局文件名为:main.xml。
2.准备工作做好了。进入程序首先是一个列表页面,用于展示已添加的事项的标题,并能显示添加新事项的按钮。
首先让我们的NotepadActivity继承ListActivity,引入“android.app.ListActivity”。
在res\lay_out下创建个布局文件notes_list.xml。
代码如下:
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/bgcolor"
android:orientation="vertical">
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/textcolor"
android:textSize="16pt" >
</ListView>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/no_notes"
android:textColor="@color/textcolor"
android:textSize="16pt" >
</TextView>
</LinearLayout>
在values/string.xml里定义几个标红的字符串常量值,值可以随意思指定。
在NotepadActivity.java中将setContentVie函数的参数改为R.layout.notes_list。
右键单击工程,RunAs --> 1. Android Application,试着跑一下,如下图。
下节我们尝试增加个添加按钮,加入新的记事。
- Android记事本【1】
- android 记事本
- android项目 之 记事本(1) ----- 界面设计
- Android学习笔记(1)------简易记事本
- Android学习笔记(1)------简易记事本
- 记事本1
- Qmemo Android记事本
- Android 记事本控件
- Android记事本程序源码
- android 简易记事本
- android疑问记事本
- Android 记事本样式
- Android记事本【2】
- Android记事本【3】
- Android记事本【4】
- Android记事本【5】
- Android记事本开发
- Android 记事本NotePad
- 看《_beginthreadex和CreateThread的区别和联系》的补遗
- android Debug时提示source not found
- 例说WIN32 Tab控件使用
- 几何和网络流的结合 战火星空
- Java基础之面向对象(六)--异常、包
- Android记事本【1】
- Makefile
- Tomcat - 认识
- 设计模式C++实现(7)——外观模式、组合模式
- solaris系统用ps命令查看进程占用的CPU、内存等情况
- 如何提高意志力&如何坚持每天学习
- 卡特兰数,值得纪念下,包括了高精度乘法和除法。
- PHP著名开源项目汇总
- 二分查找算法