Android实验报告基于文件的日程安排.docx

上传人:b****3 文档编号:10312804 上传时间:2023-05-25 格式:DOCX 页数:12 大小:17.15KB
下载 相关 举报
Android实验报告基于文件的日程安排.docx_第1页
第1页 / 共12页
Android实验报告基于文件的日程安排.docx_第2页
第2页 / 共12页
Android实验报告基于文件的日程安排.docx_第3页
第3页 / 共12页
Android实验报告基于文件的日程安排.docx_第4页
第4页 / 共12页
Android实验报告基于文件的日程安排.docx_第5页
第5页 / 共12页
Android实验报告基于文件的日程安排.docx_第6页
第6页 / 共12页
Android实验报告基于文件的日程安排.docx_第7页
第7页 / 共12页
Android实验报告基于文件的日程安排.docx_第8页
第8页 / 共12页
Android实验报告基于文件的日程安排.docx_第9页
第9页 / 共12页
Android实验报告基于文件的日程安排.docx_第10页
第10页 / 共12页
Android实验报告基于文件的日程安排.docx_第11页
第11页 / 共12页
Android实验报告基于文件的日程安排.docx_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Android实验报告基于文件的日程安排.docx

《Android实验报告基于文件的日程安排.docx》由会员分享,可在线阅读,更多相关《Android实验报告基于文件的日程安排.docx(12页珍藏版)》请在冰点文库上搜索。

Android实验报告基于文件的日程安排.docx

Android实验报告基于文件的日程安排

第三次实验基于文件的日程安排

一.实验目的及实验环境

1.实验目的

1)掌握首选项方式的存储和读取

2)掌握位于内存上的数据文件的存储和读取

3)掌握位于SD卡上的数据文件的存储和读取

2.实验环境

系统开发平AndroidStudio

系统开发平台:

Android

运行平台:

WindowsXP及以上

运行环境:

FrameworkSDK

二.实验教材、组织方式、实验内容

1.实验教材:

Andorid开发与应用

2.组织方式:

个人独立完成

2.实验内容:

实现基于文件存储的日程安排应用,数据文件可以保存在机身内存或者SD卡中。

通过单击增加图标打开新增加活动界面,通过单击保存按钮将活动内容写入到文件中,并返回前页,点击删除图标,可以删除该活动。

(保存或删除须给出提示框)

三.方案设计

写了一个三个界面,一个是已经安排的活动的界面,一个是新增加活动的界面,还有一个是浏览界面,然后增加活动的时候调用了日期选择框,对日期进行选择,然后对时间进行选择,选择之后,输入记录,然后写入文件存储起来,

下次打开app可以查看之前记录的内容。

 

四.运行结果

 

五.总结

通过这次实验掌握了首选项方式的存储和读取,掌握了位于内存上的数据文件的存储和读取以及位于SD卡上的数据文件的存储和读取

六.附录:

源代码

import

importclassMainActivityextendsActivity{

privateListlist;

privateListViewlistview;

privateMyAdapteradapter;

protectedvoidonCreate(BundlesavedInstanceState){

(savedInstanceState);

setContentViewlist=newArrayList();

list=query();

listview=(ListView)findViewByIdadapter=newMyAdapter();

(adapter);

}

publicListquery()

{

Listlist=newArrayList();

Stringstr="";

FileInputStreamfis;

try{

fis=openFileInput("");

byte[]buffer=newbyte[()];

(buffer);

str=newString(buffer);

();

}catch(Exceptione)

{}

String[]array=("\n");

for(inti=0;i<;i++)

{

Stringst=array[i];

(st);

}

returnlist;

}

publicvoidaddImage(Viewview)

{

Intentintent=newIntent();

intent=newIntent,;

startActivity(intent);

}

privateclassMyAdapterextendsBaseAdapter

{

publicintgetCount(){

return();

}

publicObjectgetItem(intposition){

return(position);

}

publiclonggetItemId(intposition){

returnposition;

}

publicViewgetView(intposition,ViewconvertView,ViewGroupparent)

{

Viewview=convertView!

=null?

convertView:

(getApplicationContext(),null);

TextViewactivity=(TextView)finalStringname=(position);

());

ImageViewdelete=(ImageView)(new(){

publicvoidonClick(Viewarg0){

new

.setTitle("确定要删除吗?

")

.setPositiveButtonnew(){

publicvoidonClick(DialogInterfacedialog,intwhich){

(name);

Stringstr="";

notifyDataSetChanged();

for(inti=0;i<();i++)

{

str+=(i).toString()+"\n";

}

FileOutputStreamfos;

try{

fos=openFileOutput("",MODE_PRIVATE);

());

();

}catch(Exceptione)

{

();

}

}

})

.setNegativeButtonnew(){

publicvoidonClick(DialogInterfacedialog,intwhich){

();

}

})

.show();

}

});

returnview;

}

}

}

xmlversion=""encoding="utf-8"?

>

android=""

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

scrollbarSize="1dip">

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

orientation="vertical">

--ToDoItemtask-->

android:

id="@+id/itemTaskLabel"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

text="@string/item_task_text"

android:

textSize="22sp"/>

android:

id="@+id/itemTaskEditText"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_gravity="left"

android:

hint="@string/addItemHint"

android:

lines="6"/>

android:

layout_width="fill_parent"

android:

layout_height="1px"

android:

background="?

android:

attr/listDivider"/>

--ToDoItemtime-->

android:

id="@+id/itemTimeLabel"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

text="@string/item_time_text"

android:

textSize="22sp"/>

style="?

android:

attr/buttonBarStyle"

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

orientation="horizontal"

android:

padding="0dip">

android:

id="@+id/dateBtn"

style="?

android:

attr/buttonBarButtonStyle"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_margin="0dip"

android:

layout_weight=""

android:

drawableLeft="@drawable/calender"

android:

padding="4dp"/>

android:

id="@+id/timeBtn"

style="?

android:

attr/buttonBarButtonStyle"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_margin="0dip"

android:

layout_weight=""

android:

drawableLeft="@drawable/clock"

android:

padding="5dp"/>

android:

layout_width="fill_parent"

android:

layout_height="1px"

android:

background="?

android:

attr/listDivider"/>

--ToDoItemalertTime-->

android:

id="@+id/alertLayout"

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

padding="5dip">

android:

id="@+id/itemAlertLabel"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

text="@string/item_alert_text"

android:

textSize="22sp"/>

android:

id="@+id/itemAlertTime"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_below="@+id/itemAlertLabel"

android:

textSize="14sp"/>

android:

id="@+id/itemAlertImageView"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignParentRight="true"

android:

layout_centerVertical="true"

android:

contentDescription="@string/item_duplicate_contentDescription"

android:

src="@drawable/add"/>

android:

id="@+id/alertTableLayout"

android:

layout_width="fill_parent"

android:

layout_height="0dip"

android:

layout_marginLeft="5dip"

android:

layout_weight="1"

android:

padding="5dip"

android:

stretchColumns="0,1">

android:

layout_width="fill_parent"

android:

layout_height="1px"

android:

background="?

android:

attr/listDivider"/>

--ToDoItemduplicate-->

android:

id="@+id/duplicateLayout"

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

padding="5dip">

android:

id="@+id/itemDuplicateLabel"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

text="@string/item_duplicate_text"

android:

textSize="22sp"/>

android:

id="@+id/itemDuplicate"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_below="@+id/itemDuplicateLabel"

android:

textSize="14sp"/>

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignParentRight="true"

android:

layout_centerVertical="true"

android:

contentDescription="@string/item_duplicate_contentDescription"

android:

src="@drawable/arrow_right"/>

android:

layout_width="fill_parent"

android:

layout_height="1px"

android:

background="?

android:

attr/listDivider"/>

--ToDoItempriority-->

android:

id="@+id/priorityLayout"

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

padding="5dip">

android:

id="@+id/itemPriorityLabel"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

text="@string/item_priority_text"

android:

textSize="22sp"/>

android:

id="@+id/itemPriority"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_below="@+id/itemPriorityLabel"

android:

textSize="14sp"/>

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignParentRight="true"

android:

layout_centerVertical="true"

android:

contentDescription="@string/item_duplicate_contentDescription"

android:

src="@drawable/arrow_right"/>

android:

layout_width="fill_parent"

android:

layout_height="1px"

android:

background="?

android:

attr/listDivider"/>

xmlversion=""encoding="utf-8"?

>

日程安排

新增活动

新的活动

删除

修改

保存

取消

新增

日历

时间

今天

现在

请选择日期

请选择时间

事项

时间

提醒

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

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

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