ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:56.16KB ,
资源ID:10209409      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-10209409.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Android开发之Eclipse制作简易备忘录.docx)为本站会员(b****3)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

Android开发之Eclipse制作简易备忘录.docx

1、Android开发之Eclipse制作简易备忘录Android 开发之Eclipse制作“备忘录备忘录,或者说是便签,其实界面设计比较简单,机载的一些便签也是比较简单的设计,当然,如果想让画面更加绚丽点,可以融合进相应技术,在这里,我就做一些简单的设计.界面之外,主要是文件的存储与读取,设计到java编程的IO流操作,相信对于有着一定的java基础的人都是很容易去理解的.UI图如下:下面简单介绍一下我制作这个备忘录的过程。首先做UI设计,具体设计相信只是时间问题,很好解决,直接编写xml布局文件,对于该备忘录,我设计了3个xml布局文件,其中第一个是activity_main.xml,第二个是

2、about.xml(里面存放的是copyrights信息),第三个是details.xml(里面是用于显示某条选中记录的完整信息),三个布局分别如下:除了第一个布局,另外两个布局都有back按钮,用于返回到主界面。三个布局的布局文件应该是很容易写的,需要注意的是,需要设置响应的id,以便在主函数中进行消息响应。三个布局文件的代码分别是:activity_main.xml LinearLayout android:id=+id/linearLayout1” android:layout_alignParentLeft=”true” android:layout_marginLeft=15dp”

3、android:layout_marginRight=15dp” android:layout_width=”match_parent android:layout_height=wrap_content android:layout_below=id/bt_write android:layout_marginTop=5dp android:orientation=vertical TextView android:id=+id/note_saved1 android:clickable=true android:layout_width=”match_parent android:layo

4、ut_height=wrap_content” android:background=#96C8A8” android:layout_marginBottom=5dp android:textColor=177C50 android:lines=”1” android:textSize=20dp” / TextView android:id=”+id/note_saved2” android:layout_width=match_parent android:layout_height=wrap_content android:background=”#96C8A8” android:layo

5、ut_marginBottom=”5dp android:textColor=”177C50” android:textSize=”20dp” android:lines=1” android:clickable=true”/ TextView android:id=”+id/note_saved3 android:clickable=”true” android:layout_width=”match_parent” android:background=96C8A8” android:layout_height=wrap_content” android:layout_marginBott

6、om=5dp” android:textColor=”#177C50” android:lines=”1 android:textSize=”20dp” / TextView android:id=+id/note_saved4” android:clickable=”true android:layout_width=”match_parent android:layout_height=”wrap_content” android:background=”#96C8A8” android:layout_alignLeft=+id/linearLayout1 android:layout_b

7、elow=”+id/linearLayout1” android:layout_marginBottom=”5dp” android:textColor=”#177C50 android:lines=1 android:textSize=20dp / /LinearLayout Button android:id=+id/bt_rewrite” android:layout_width=wrap_content android:layout_height=wrap_content” android:layout_alignBottom=+id/bt_save” android:layout_a

8、lignTop=+id/bt_save” android:layout_toRightOf=+id/bt_save android:shadowColor=#263646 android:text=”clear android:textColor=#541717” android:width=40dp / Button android:id=+id/bt_up android:layout_width=wrap_content” android:layout_height=wrap_content” android:layout_alignBaseline=+id/bt_down” andro

9、id:layout_alignBottom=”+id/bt_down” android:layout_alignRight=+id/linearLayout1 android:text=”up” / detail.xml:?xml version=”1。0” encoding=utf8”? TextView android:id=”+id/tv_details” android:layout_height=”wrap_content android:layout_width=match_parent android:maxLines=8 android:textColor=2E37AA and

10、roid:textSize=”20dp” android:lines=”8” android:text=hello/ Button android:id=+id/bt_back android:layout_width=”wrap_content” android:layout_height=wrap_content android:layout_alignParentRight=”true android:layout_below=”+id/tv_details android:layout_marginRight=16dp” android:layout_marginTop=”46dp”

11、android:text=”back” /RelativeLayout至此,界面布置完成,相应的控件ID都已合理的设置,接下来,需要写主函数以及用于IO存储的函数。下面对诸多按钮的功能进行一一叙述:“write”设置光标可见,设置编辑区清空“save存储TextView(也就是编辑框)里的内容到相应的xxx.txt 里面,该txt文件将存储在手机内存中。“clear”backspace的作用“about-作者信息与app信息“up”记录向上滚动“down”记录向下滚动“first”首页按下每个小TextView时,将进入记录具体内容演示界面,其中按下“back”将返回主界面.功能补述:::由于

12、记录是存储在手机内存中的,因此,希望每次启动app时候,能载入已经存储好了的记录,且按照习惯,载入最近的几条记录,并可实现记录翻页取出.因此,文件既涉及到存,也涉及到读,为实现存储文件和读取文件,编写noteService类,里面包含读、写函数,具体代码如下:public class noteService public static boolean saveContent(Context context,String content,int saveCountor) String str = ”content+saveCountor; try File file = new File(con

13、text。getFilesDir(),str); FileOutputStream fos = new FileOutputStream(file); fos.write((content).getBytes()); fos。close(); return true; catch (Exception e) e.printStackTrace(); return false; public static String getSavedContent(Context context,int saveCountor) String str = ”content”+saveCountor; File

14、 file = new File(context.getFilesDir(),str); try FileInputStream fis = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); String str1 = br。readLine(); return str1; catch (Exception e) e。printStackTrace(); return null; 此类中没有定义实例化对象函数。定义好noteService类后,接下来需要编

15、写主函数了。为了实现上述功能,主函数需要对相应事件进行监听,进行相应的处理,并力争减少bug,顾经过反复调试,主类代码为:package com.example。xiongyanan.notes;import java.io。File;import android.os。Bundle;import android。support。v7。app.ActionBarActivity;import android。view。View;import android.view。View。OnClickListener;import android.widget.Button;import android

16、。widget。EditText;import android。widget。TextView;import android.widget.Toast;public class MainActivity extends ActionBarActivity implements OnClickListener private int saveCountor; private int saveCountorImage; private File file; private EditText et_content; private Button bt_back; private TextView t

17、v_details; protected void onCreate(Bundle savedInstanceState) int i=1; super.onCreate(savedInstanceState); setContentView(R。layout。activity_main); btSet(); do String str = ”content”+i; file = new File(this.getFilesDir(),str); i+; while(file.exists()); saveCountor=i-1; contentFindSet(); saveCountorIm

18、age=saveCountor; private void contentFindSet() TextView note_save1 = (TextView)this。findViewById(R.id.note_saved1); TextView note_save2 = (TextView)this。findViewById(R.id。note_saved2); TextView note_save3 = (TextView)this.findViewById(R。id。note_saved3); TextView note_save4 = (TextView)this。findViewB

19、yId(R。id。note_saved4); TextView note_save5 = (TextView)this。findViewById(R.id。note_saved5); if(saveCountor5) note_save1.setText(No Saved); note_save2。setText(”); note_save3。setText(”); note_save4.setText(); note_save5.setText(”); else note_save1。setText((CharSequence)noteService。getSavedContent(Main

20、Activity.this, saveCountor1)); note_save2.setText((CharSequence)noteService.getSavedContent(MainActivity。this, saveCountor2)); note_save3.setText(CharSequence)noteService.getSavedContent(MainActivity。this, saveCountor-3); note_save4。setText((CharSequence)noteService.getSavedContent(MainActivity.this, saveCountor-4));note_save5。setText(CharSequence)noteService。getSavedContent(MainActivity.this, saveCountor-5); private void contentFindSet(int saveCountor) TextView note_save1 = (TextView)this。findViewById(R。id.note_saved1); TextView note_save2 =

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2