res/layout 目录下的 main.xml 源码 : <?xml version="1.0" encoding="utf 8"?> <TabHost android:layout_height="fill_parent" xml

Similar documents
主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

Android Service

多媒體應用 13 新增專案並完成版面配置 <ExMusic01> <activity_main.xml> ImageView ID imgplay ImageView ID imgstop ImageView ID imgfront TextView ID txtsong TextView ID t

Dynamic Layout in Android

單步除錯 (1/10) 打開 Android Studio, 點選 Start a new Android Studio project 建立專案 Application name 輸入 BMI 點下 Next 2 P a g e

Lecture01_Android介绍

预览图 : (2) 在 SelectCity.java 中增加控件, 用于绑定 select_city 文件的 ListView, TextView,EditTest 等控件 代码和注释如下 :

Android Fragment

Lecture01_Android介绍

单击以编辑母片 Content 标题样式 LinearLayout 排版模式 TableLayout 排版模式 RelativeLayout 排版模式 AbsoluteLayout 排版模式 FrameLayout 排版模式 GridLayout 排版模式 TabWidget 切換卡 Lab 5 2

Android 开发教程

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入

Android 开发教程

Android Android Android SDK iv

用手機直接傳值不透過網頁連接, 來當作搖控器控制家電 ( 電視遙控器 ) 按下按鍵發送同時會回傳值來確定是否有送出 問題 :1. 應該是使用了太多 thread 導致在傳值上有問題 2. 一次按很多次按鈕沒辦法即時反應

新・解きながら学ぶJava

RecyclerView and CardVew

第一章 Android 简介与开发环境搭建

0511-Android程式之GPS應用_專題週記4

「西醫基層總額支付委員會《第28次委員會議紀錄

The Embedded computing platform

建模与图形思考

PowerPoint 簡報

Microsoft Word - Android 7.x.doc

Android 编程基础 Android 开发教程 & 笔记 1

Microsoft Word - 第4章 3D相册.doc

Microsoft Word - 02.目錄.doc

天仁期末個人報告1.PDF

Microsoft PowerPoint - ch6 [相容模式]

1.5招募说明书(草案)

Microsoft Word - 第3章.doc

Java

山东建筑大学学分制管理规定(试行)


图 6-1 主界面 MainActivity 界面对应的布局文件 (activity_main.xml) 如下所示 : <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="

题目

使用MapReduce读取XML文件

03 开发入门.key

教育部補助資訊軟體人才培育先導計畫 100 年度課程發展專案計畫 實驗課程名稱 : IPC(Inter-Process Communication) 開發教師 : 張晉源老師 開發學生 : 林政揚 學校系所 : 樹德科技大學資訊工程學系

建立Android新專案

Microsoft Word 杨超-spinner实现省市县的三级联动.docx

Chapter 4

Microsoft Word - 01.DOC

人民邮电

内文-2.indd

ShareText

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

Microsoft Word - 第3章.doc

Microsoft Word - weather12 刷新按钮动画+搜索框+bug处理.docx

Database_001

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 ->

Microsoft PowerPoint - 03 开发入门.ppt [兼容模式]

Microsoft PowerPoint - 04 界面编程.ppt [兼容模式]

Chapter 1: Introduction

Microsoft PowerPoint - 07.Android 介面元件-TableLayout、Toast、AlertDialog

建模与图形思考

1: public class MyOutputStream implements AutoCloseable { 3: public void close() throws IOException { 4: throw new IOException(); 5: } 6:

政府再造的基本精神:小而美或小而能?

中 文 摘 要 智 慧 型 手 機 由 於 有 強 大 的 功 能, 以 及 優 渥 的 便 利 性, 還 能 與 網 路 保 持 隨 時 的 鏈 結 與 同 步 更 新, 因 此 深 受 廣 大 消 費 者 喜 愛, 當 然, 手 機 遊 戲 也 成 為 現 代 人 不 可 或 缺 的 娛 樂 之

JavaIO.PDF

内 容 简 介 本 书 是 一 本 关 于 语 言 程 序 设 计 的 教 材, 涵 盖 了 语 言 的 基 本 语 法 和 编 程 技 术, 其 中 包 含 了 作 者 对 语 言 多 年 开 发 经 验 的 总 结, 目 的 是 让 初 学 的 读 者 感 受 到 语 言 的 魅 力, 并 掌

Chapter 10

OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数

投影片 1

Microsoft PowerPoint - chapter05.ppt

Microsoft Word - Hibernate与Struts2和Spring组合指导.doc

2 Java 语 言 程 序 设 计 教 程 简 单 性 Java 语 言 的 语 法 与 C 语 言 和 C++ 语 言 很 接 近, 使 得 大 多 数 程 序 员 很 容 易 学 习 和 使 用 Java 另 一 方 面,Java 丢 弃 了 C++ 中 很 少 使 用 的 很 难

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes

Android + NFC

目 录 第 一 章 调 查 介 绍 调 查 方 法 调 查 对 象 调 查 规 模 调 查 方 式 调 查 内 容 术 语 界 定... 4 第 二 章 报 告 概

在Spring中使用Kafka:Producer篇

Java Access 5-1 Server Client Client Server Server Client 5-2 DataInputStream Class java.io.datainptstream (extends) FilterInputStream InputStream Obj

Microsoft Word - 扉页.doc

_banneradview.settest(true); _banneradview.setuserkeywords("swimming"); _banneradview.setusercategories("1,3,4"); _banneradview.setusergender(jdbanner

版权声明

Android 基礎教學

任务实施 (1) 创建项目 图 3-1 欢迎界面 首先创建一个工程, 将其命名为 BoXueGu, 指定包名为 com.boxuegu (2) 导入界面图片将欢迎界面所需要的背景图片 launch_bg.png 导入到 drawable 文件夹中, 项目的 icon 图标 app_icon.png

幻灯片 1

小应用 Magic8

實作SQLiteOpenHelper類別

XXX说明书

使 用 Java 语 言 模 拟 保 险 箱 容 量 门 板 厚 度 箱 体 厚 度 属 性 锁 具 类 型 开 保 险 箱 关 保 险 箱 动 作 存 取 款

untitled

1.5招募说明书(草案)

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class

上海市教育委员会文件

Chapter 16 Widget 作者 : 林致孙 不少 Android 手機在使用者剛購買時, 手機的桌面上就已經有不少的小工具 (Widget), 有些可以即時顯示氣候資訊, 有些則可以顯示最新股票資訊 本章將 利用兩個例子來說明 Widget 是如何設計的 16.1 時辰顯示小工具 在 An

OOP with Java 通知 Project 4: 4 月 19 日晚 9 点

软件工程文档编制

<4D F736F F D20B5DA35D5C220D3C3BBA7BDE7C3E6BFAAB7A22E646F6378>

Java java.lang.math Java Java.util.Random : ArithmeticException int zero = 0; try { int i= 72 / zero ; }catch (ArithmeticException e ) { // } 0,

<android.support.v7.widget.recyclerview android:layout_width="0dp" android:layout_height="0dp" android:layout_marginbottom

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

Microsoft Word - 第3章.doc

90 深入 Android 应用开发 核心技术解析与最佳实践 -> android.view.viewgroup -> android.widget.linearlayout 对于 LinearLayout 而言 有几个重要的属性必须注意 android:layout_width 属性定义了控 件的

Android + WebService

Android线程和进程

目 錄 一 ANDROID 開發系統需求 作業系統 開發工具... 1 二 安裝 ANDROID 開發工具 安裝 JDK 使用 APT-GET 安裝 使用套件管理程式安裝... 9 三 ANDROID 程式撰寫... 1

Transcription:

拓展训练 1- 界面布局 1. 界面布局的重要性做应用程序, 界面是最基本的 Andorid 的界面, 需要写在 res/layout 的 xml 里面, 一般情况下一个 xml 对应一个界面 Android 界面布局有点像写 html( 连注释代码的方式都一样 ), 要先给 Android 定框架, 然后再在框架里面放控件,Android 提供了几种框架,AbsoluteLayout,LinearLayout, RelativeLayout,TableLayout,FrameLayout FrameLayout: 里面只可以有一个控件, 并且不能设计这个控件的位置, 控件会放到左上角 ; LinearLayout: 里面可以放多个控件, 但是一行只能放一个控件 ; TableLayout: 这个要和 TableRow 配合使用, 很像 html 里面的 table; AbsoluteLayout: 里面可以放多个控件, 并且可以自己定义控件的 x,y 的位置 ; RelativeLayout: 里面可以放多个控件, 不过控件的位置都是相对位置 2. 拓展实例电大应用程序的界面布局采用的是 LinearLayout 和 FrameLayout 相结合的方式 如图 1 所示, 是该应用程序结构图 : 图 1 程序结构图 2.1 界面布局 xml 文件

res/layout 目录下的 main.xml 源码 : <?xml version="1.0" encoding="utf 8"?> <TabHost android:id="@android:id/tabhost" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:orientation="vertical" android:layout_height="fill_parent"> <FrameLayout android:id="@+id/msg_title" android:visibility="gone" android:layout_height="wrap_content"> <TextView android:id="@+id/tv_wb" android:layout_height="wrap_content" android:background="@drawable/titlebar_lightgray_bg"></textview> </FrameLayout> <FrameLayout android:id="@android:id/tabcontent" android:layout_height="0.0dip" android:layout_weight="1.0" android:theme="@android:style/theme.black.notitlebar.fullscreen"/> <TabWidget android:id="@android:id/tabs" android:visibility="gone" android:layout_height="wrap_content" android:layout_weight="0.0" /> <RadioGroup android:gravity="center_vertical" android:layout_gravity="bottom" android:orientation="horizontal" android:id="@id/main_radio" android:background="@drawable/header" android:layout_height="wrap_content"> <RadioButton android:id="@+id/radio_button0" android:tag="radio_button0"

android:text="@string/main_home" android:drawabletop="@drawable/home" <RadioButton android:id="@+id/radio_button7" android:tag="radio_button7" android:text="@string/ddjj" android:drawabletop="@drawable/ddjj" <RadioButton android:id="@+id/radio_button1" android:tag="radio_button1" android:text="@string/main_news" android:drawabletop="@drawable/diqiu" <RadioButton android:id="@+id/radio_button2" android:tag="radio_button2" android:text="@string/main_my_info" android:drawabletop="@drawable/shu" <RadioButton android:id="@+id/radio_button3" android:tag="radio_button3" android:text="@string/mobile_classroom" android:drawabletop="@drawable/mobile_classroom" <RadioButton android:id="@+id/radio_button5" android:tag="radio_button5"

android:text="@string/video" android:drawabletop="@drawable/video" <RadioButton android:id="@+id/radio_button6" android:tag="radio_button6" android:text="@string/media" android:drawabletop="@drawable/media" <RadioButton android:id="@+id/radio_button8" android:tag="radio_button8" android:text="@string/more" android:drawabletop="@drawable/more" style="@style/main_tab_bottom"/> </RadioGroup> </LinearLayout> </TabHost> 2.2 界面程序源码 src 目录下的 shouye.java 源码 : package my.dianda.third; import android.app.tabactivity; import android.content.intent; import android.os.bundle; //import android.util.log; import android.widget.radiogroup; import android.widget.radiogroup.oncheckedchangelistener; import android.widget.tabhost; import android.widget.tabhost.tabspec; //import pei.popupwindow.popupwindow_peiactivity;

public class shouye extends TabActivity { /** Called when the activity is first created. */ public TabHost mth; public static final String TAB_HOME=" 首页 "; public static final String TAB_NEWS=" 电大新闻 "; public static final String TAB_Library=" 移动图书馆 "; public static final String TAB_CLASS=" 移动课堂 "; // public static final String TAB_ZHAO=" 语音服务 "; public static final String TAB_Media=" 音频服务 "; public static final String TAB_Vedio=" 视频服务 "; public static final String TAB_JIAN=" 电大简介 "; public static final String TAB_MORE="More"; public RadioGroup radiogroup; @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); mth=this.gettabhost(); TabSpec ts1=mth.newtabspec(tab_home).setindicator(tab_home); ts1.setcontent(new Intent(shouye.this,zhuye.class)); mth.addtab(ts1); TabSpec ts2=mth.newtabspec(tab_news).setindicator(tab_news); ts2.setcontent(new Intent(shouye.this,news.class)); mth.addtab(ts2); TabSpec ts3=mth.newtabspec(tab_library).setindicator(tab_library); ts3.setcontent(new Intent(shouye.this,book.class)); mth.addtab(ts3); TabSpec ts4=mth.newtabspec(tab_class).setindicator(tab_class); ts4.setcontent(new Intent(shouye.this,yidongke.class)); mth.addtab(ts4); // TabSpec ts5=mth.newtabspec(tab_zhao).setindicator(tab_zhao); // ts5.setcontent(new Intent(shouye.this,yuyin.class)); // mth.addtab(ts5); TabSpec ts6=mth.newtabspec(tab_vedio).setindicator(tab_vedio);

ts6.setcontent(new Intent(shouye.this,vediohome.class)); mth.addtab(ts6); TabSpec ts7=mth.newtabspec(tab_media).setindicator(tab_media); ts7.setcontent(new Intent(shouye.this,mediahome.class)); mth.addtab(ts7); TabSpec ts8=mth.newtabspec(tab_jian).setindicator(tab_jian); ts8.setcontent(new Intent(shouye.this,net.fiex.list.FlexListActivity.class)); mth.addtab(ts8); TabSpec ts9=mth.newtabspec(tab_more).setindicator(tab_more); ts9.setcontent(new Intent(shouye.this,pei.popupwindow.PopUpWindow_PeiActivity.class)); mth.addtab(ts9); this.radiogroup=(radiogroup)findviewbyid(r.id.main_radio); radiogroup.setoncheckedchangelistener(new OnCheckedChangeListener() { { @Override public void oncheckedchanged(radiogroup group, int checkedid) // TODO Auto generated method stub switch(checkedid){ case R.id.radio_button0: mth.setcurrenttabbytag(tab_home); case R.id.radio_button7: mth.setcurrenttabbytag(tab_jian); case R.id.radio_button1: mth.setcurrenttabbytag(tab_news); case R.id.radio_button2: mth.setcurrenttabbytag(tab_library); case R.id.radio_button3: mth.setcurrenttabbytag(tab_class); // case R.id.radio_button4: // mth.setcurrenttabbytag(tab_zhao);

// case R.id.radio_button5: mth.setcurrenttabbytag(tab_vedio); case R.id.radio_button6: mth.setcurrenttabbytag(tab_media); }); } case R.id.radio_button8: mth.setcurrenttabbytag(tab_more); } } 2.3 界面布局效果图 程序运行后, 显示主界面结果如图 2 所示 : 3. 源程序下载 Layout.zip 图 2 程序运行后的界面布局