---
title: "Android开发新手学习-inote记事工具"
author: "jandroid"
date: "2011-10-18T10:34:00Z"
tags: []
slug: "android-inote"
draft: false
lastmod: "2011-10-19T13:52:36Z"
id: 1201533
url: "https://jandroid.iteye.com/blog/1201533"
---

**Android****开发新手学习**

[源码及APK下载](http://files.note.sdo.com/7pq1Y~jFlqbMLX0GA004jr)：http://files.note.sdo.com/7pq1Y~jFlqbMLX0GA004jr （如果你有改进，不妨发我也学习下 xuchangyuhui@sohu.com）

这些天在学习Android开发，本着先上手的原则，尝试开发了一个简单的记事工具inote。开发过程收获不少，这里罗列一些作为新手学到的知识。希望对其他新手学习有益。

## 手机及开发环境

手机

HTC Magic（G2）

屏幕

320×480

Android版本

2.1-update1

Eclipse

GALILEO

## 记事工具inote

### 功能

1.新增、编辑和删除（仅支持文本；非彻底删除，可恢复）

2.记事锁（一个主密码，适用所有记事）

3.搜索（支持标题、内容）

4.导出（导出txt文件至SD卡）

5.分享

### 截图

![](http://files.note.sdo.com/7pq1Y~jFlnoFnM0L4004NU)![](http://files.note.sdo.com/7pq1Y~jFlnqFnM0L4004NX)![](http://files.note.sdo.com/7pq1Y~jFlnspnM0L4004N_)

![](http://files.note.sdo.com/7pq1Y~jFlnv9nM0L4004O2)![](http://files.note.sdo.com/7pq1Y~jFlnyVnM0L4004Oe)

## Android界面术语

ActionBar、ContextMenu、ToolBar

![](http://files.note.sdo.com/7pq1Y~jFlnWpnM0L4004O-)

ActionBar：3.0以上提供，3.0以下需要自行实现

（本人参考的是johannilsson-android-actionbar，[https://github.com/johannilsson/android-actionbar](https://github.com/johannilsson/android-actionbar)）

Dashboard

![](http://files.note.sdo.com/7pq1Y~jFln_FnM0L4004P2)

OptionsMenu

![](http://files.note.sdo.com/7pq1Y~jFlob9nM0L4004Ps)

其他控件可以在界面编辑的时候看到，种类很多，足够做一些基本应用了。

在界面设计时，可以参考[http://www.androidpatterns.com/](http://www.androidpatterns.com/)，提供了很多设计原则

This is androidpatterns.com, a set of interaction patterns that can help you design Android apps. An interaction pattern is a short hand summary of a design solution that has proven to work more than once. Please be inspired: use them as a guide, not as a law.

![](http://files.note.sdo.com/7pq1Y~jFloxpnM0L4004Pz)

## inote新手开发

1.创建的Activity要添加到AndroidManifest.xml文件

2.可以使用AlertDialog实现如下的弹出窗口（不设置Title和Icon）

AlertDialog.Builder builder =**new**AlertDialog.Builder(**this**);

View view = LayoutInflater.*from*(**this**).inflate(R.layout.*search\_pop*,**null**);

builder.setView(view);

builder.show();

![](http://files.note.sdo.com/7pq1Y~jFlnv9nM0L4004O2)

3.输入框的提示文字（没有内容时展现），设置EditText的android:hint="@string/content"属性。

![](http://files.note.sdo.com/7pq1Y~jFloIVnM0L4004PG)

4.分享功能的实现。

**privatevoid**share() {

**final**Intent intent =**new**Intent(Intent.*ACTION\_SEND*);

intent.setType("text/plain");

intent.putExtra(Intent.*EXTRA\_SUBJECT*,note.title);

intent.putExtra(Intent.*EXTRA\_TEXT*,note.content);

Intent.*createChooser*(intent,"Share");

startActivity(intent);

}

![](http://files.note.sdo.com/7pq1Y~jFloQFnM0L4004PL)

5.SQLiteOpenHelper在系统目录创建数据库，如果要把数据库文件保存在SD卡，可通过SQLiteDatabase.openOrCreateDatabase自行实现。

6.SD卡的访问，需在AndroidManifest.xml添加权限。

&lt;uses-permission android:name="android.permission.WRITE\_EXTERNAL\_STORAGE"/&gt;

7.设置RadioButton组

&lt;RadioGroupandroid:id=*"@+id/searchRadioGroup"*

android:layout\_width=*"wrap\_content"*

android:layout\_height=*"wrap\_content"*

android:orientation=*"horizontal"*&gt;

&lt;RadioButtonandroid:layout\_height=*"wrap\_content"*

android:text=*"@string/title"*

android:layout\_width=*"wrap\_content"*

android:id=*"@+id/titleRadio"*

android:checked=*"true"*/&gt;

&lt;RadioButton

android:layout\_height=*"wrap\_content"*

android:text=*"@string/content"*

android:layout\_width=*"wrap\_content"*

android:id=*"@+id/ContentRadio"*/&gt;

&lt;RadioButtonandroid:layout\_height=*"wrap\_content"*

android:text=*"@string/all"*

android:layout\_width=*"wrap\_content"*

android:id=*"@+id/allRadio"*/&gt;

&lt;/RadioGroup&gt;

8.设置窗口，可以通过PreferenceScreen、PreferenceActivity实现。（inote这个版本未实现）

![](http://files.note.sdo.com/7pq1Y~jFloUpnM0L4004PP)

9.指定EditBox只能输入数字（或其他），设置android:inputType="number"。

![](http://files.note.sdo.com/7pq1Y~jFloXFnM0L4004PS)

更多内容直接看代码吧，代码为新手学习，有什么问题可以给我回馈。（xuchangyuhui@sohu.com）

[源码及APK下载](http://files.note.sdo.com/7pq1Y~jFlqbMLX0GA004jr)：http://files.note.sdo.com/7pq1Y~jFlqbMLX0GA004jr