计科1141班胡志泉安卓实验6 - 数据存储与访问
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
GDOU-B-11-112广东海洋大学学生实验报告书(学生用表)实验名称实验6:数据存储与访问课程名称移动编程课程号16242215x0学院(系) 数学与计算机专业计算机科学与技术班级计科1141班学生姓名学号实验地点科技楼425 实验日期2017.4.1
一、实验目的
1.熟悉在Android Studio开发环境下编写Android应用程序的流程;
2.理解在Android Studio开发环境下进行用户界面设计的基本方法;
3.掌握应用Android碎片控件Fragment开发适用于大屏幕的应用程序的方法。
4.掌握应用Android存储方法SharePreferences的应用方法。
二、实验内容
在Android Studio开发环境下,使用Android的Fragment碎片控件、TextView文本标签控件、ListView列表控件、FrameLayout框架布局控件,利用SharePreferences存储方法,采用双页显示模式实现一个适用于大屏幕设备的简易新闻阅读器应用程序。
三、实验设备
Android Studio
四、实验结果
用户界面布局设计采用了水平线性布局方式,分为左右两个碎片Fragment;其中,左侧为新闻标题列表子界面,右侧为新闻详细内容子界面。当点击新闻标题列表中的某一标题时,右侧的Fragment将显示相应新闻标题的详细内容。
五、源代码
主Activity的布局文件activity_main.xml的源代码
android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="16dp" android:paddingRight="16dp" android:paddingTop="16dp" android:paddingBottom="16dp" android:orientation="horizontal"> android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:id="@+id/fl_title"> android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:id="@+id/fl_content">
新闻标题列表的布局资源文件news_title_frag.xml的源代码
android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/news_title_list_view" />
新闻标题列表子项的布局资源文件news_item.xml的源代码
android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:id="@+id/news_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" //singleLine属性设置为true表示该TextView只能单行显示 android:ellipsize="end" //ellipsize属性用于设定当文本内容超出控件宽度时,文本的缩略方式,这里设置为end表示在尾部进行缩略 android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="15dp" android:paddingBottom="15dp" android:textSize="10sp" /> //textSize属性用于设置文本大小,推荐单位为sp(放大像素, scaled pixels)
新闻内容的布局资源文件news_content_frag.xml的源代码
android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> android:id="@+id/news_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="10dp" android:textSize="15sp" />