Android开发新手学习
源码及APK下载: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.分享
截图
Android界面术语
ActionBar、ContextMenu、ToolBar
ActionBar:3.0以上提供,3.0以下需要自行实现
Dashboard
OptionsMenu
其他控件可以在界面编辑的时候看到,种类很多,足够做一些基本应用了。
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.
inote新手开发
1.创建的Activity要添加到AndroidManifest.xml文件
2.可以使用AlertDialog实现如下的弹出窗口(不设置Title和Icon)
AlertDialog.Builder builder =newAlertDialog.Builder(this);
View view = LayoutInflater.from(this).inflate(R.layout.search_pop,null);
builder.setView(view);
builder.show();
3.输入框的提示文字(没有内容时展现),设置EditText的android:hint="@string/content"属性。
4.分享功能的实现。
privatevoidshare() {
finalIntent intent =newIntent(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);
}
5.SQLiteOpenHelper在系统目录创建数据库,如果要把数据库文件保存在SD卡,可通过SQLiteDatabase.openOrCreateDatabase自行实现。
6.SD卡的访问,需在AndroidManifest.xml添加权限。
7.设置RadioButton组
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:text="@string/title"
android:layout_width="wrap_content"
android:id="@+id/titleRadio"
android:checked="true"/>
android:layout_height="wrap_content"
android:text="@string/content"
android:layout_width="wrap_content"
android:id="@+id/ContentRadio"/>
android:text="@string/all"
android:layout_width="wrap_content"
android:id="@+id/allRadio"/>
8.设置窗口,可以通过PreferenceScreen、PreferenceActivity实现。(inote这个版本未实现)
9.指定EditBox只能输入数字(或其他),设置android:inputType="number"。
更多内容直接看代码吧,代码为新手学习,有什么问题可以给我回馈。(xuchangyuhui@sohu.com)
源码及APK下载:http://files.note.sdo.com/7pq1Y~jFlqbMLX0GA004jr