項目二智慧城市界面的實現(xiàn)任務5用戶注冊開發(fā)_第1頁
項目二智慧城市界面的實現(xiàn)任務5用戶注冊開發(fā)_第2頁
項目二智慧城市界面的實現(xiàn)任務5用戶注冊開發(fā)_第3頁
項目二智慧城市界面的實現(xiàn)任務5用戶注冊開發(fā)_第4頁
項目二智慧城市界面的實現(xiàn)任務5用戶注冊開發(fā)_第5頁
已閱讀5頁,還剩20頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

Android物聯(lián)網(wǎng)應用程序開發(fā)資源轉化系統(tǒng)教材

任務實現(xiàn)知識準備任務目標目錄

任務5用戶注冊界面開發(fā)項目2智慧城市界面的實現(xiàn)

使用RelativeLayout布局管理器和CheckBox控件及RadioGroup控件實現(xiàn)用戶注冊界面開發(fā)。該界面用于輸入用戶的注冊信息,包括用戶名,郵箱,密碼及確認密碼的輸入,并進行性別的選擇,進行是否顯示密碼和同意協(xié)議的多選,最后點擊注冊,實現(xiàn)注冊功能。

【任務目標】1.掌握RelativeLayout布局的使用方法2.掌握RadioButton和RadioGroup控件的使用方法3.掌握CheckBox控件的使用方法1.RelativeLayout布局的使用

【知識準備】在Android中,相對布局是指按照組件之間的相對位置進行布局,這種方式允許子元素指定它們相對于其他元素或父元素的位置(通過ID指定)。在開發(fā)中,可以在XML布局文件定義相對布局管理器,其基本語法如下:<RelativeLayoutxmlns:android="/apk/res/android"

屬性列表>

組件列表</RelativeLayout>1.RelativeLayout布局的使用

【知識準備】RelativeLayout常見的XML屬性列表XML屬性說明android:layout_above其屬性值為其他UI組件的id屬性,用于指定該組件位于哪個組件的上方android:layout_alignBottom其屬性值為其他UI組件的id屬性,用于指定該組件與哪個組件的下邊界對齊android:layout_alignLeft其屬性值為其他UI組件的id屬性,用于指定該組件與哪個組件的左邊界對齊android:layout_alignParentBottom其屬性值為boolean值,用于指定該組件是否與布局管理器底端對齊android:layout_alignParentLeft其屬性值為boolean值,用于指定該組件是否與布局管理器左邊對齊1.RelativeLayout布局的使用

【知識準備】android:layout_alignParentRight其屬性值為boolean值,用于指定該組件是否與布局管理器右邊對齊android:layout_alignParentTop其屬性值為boolean值,用于指定該組件是否與布局管理器頂端對齊android:layout_alignRight其屬性值為其他UI組件的id屬性,用于指定該組件與哪個組件的右邊界對齊android:layout_alignTop其屬性值為其他UI組件的id屬性,用于指定該組件與哪個組件的上邊界對齊android:layout_below其屬性值為其他UI組件的id屬性,用于指定該組件位于哪個組件的下方android:layout_centerHorizontal其屬性值為boolean值,用于指定該組件是否位于布局管理器水平居中的位置android:layout_centerInParent其屬性值為boolean值,用于指定該組件是否位于布局管理器的中央位置2.RadioButton和RadioGroup控件的使用方法

【知識準備】在Android中,單選按鈕(RadioButton)繼承了普通按鈕。因此,它們都可以直接使用普通按鈕支持的的各種屬性和方法。單選按鈕(RadioButton),可以通過在XML布局文件中使用<RadioButton>標記添加,其基本語法格式如下:<RadioButton<RadioButton

屬性列表或者

屬性列表>/></RadioButton>2.RadioButton和RadioGroup控件的使用方法

【知識準備】RadioButton常見的XML屬性列表XML屬性說明android:checked其屬性值用于指定選中的狀態(tài),其值為true時,表示選中;其值為false時,表示取消選中,默認為false若要RadioButton組件與RadioGroup組件一起使用時,即構成一個單選按鈕組。在XML布局文件中,添加RadioGroup組件的基本語法格式如下:<RadioGroup

屬性列表<!—添加多個RadioGroup組件-->></RadioGroup>3.CheckBox控件的使用

【知識準備】在Android中,復選框用CheckBox表示,而CheckBox類是Button類的子類,所以可以直接使用Button支持的各種屬性??梢酝ㄟ^在XML布局文件中使用<CheckBox>標記添加,其語法格式如下:<CheckBox

屬性列表></CheckBox>

【任務實現(xiàn)】在Eclipse下創(chuàng)建一個Android項目,命名為AndroidDemo2.5,實現(xiàn)用戶注冊界面開發(fā)。1)修改res/layout目錄下的布局文件,首先添加一個相對布局管理器,在該布局管理器中嵌套添加一個線性布局管理器。其代碼如下:并在其在內部添加四個線性布局管理器,在第一個線性布局管理器中,添加一個TextView控件和一個EditText控件,實現(xiàn)用戶名的輸入

<RelativeLayoutxmlns:android="/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="@drawable/bg_environment">

<LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_margin="30dp"android:background="@drawable/bg_frame_descend_setting"android:gravity="center_horizontal"android:orientation="vertical"android:padding="15dip"></LinearLayout></RelativeLayout>【任務實現(xiàn)】

2)在其在內部添加四個線性布局管理器,在第一個線性布局管理器中,添加一個TextView控件和一個EditText控件,實現(xiàn)用戶名的輸入。其代碼如下:

<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="50dp"android:layout_marginRight="50dp"><TextViewandroid:id="@+id/textView1"android:layout_width="0.0dp"android:layout_height="wrap_content"android:gravity="right"android:layout_weight="2"android:text="賬號:"http://顯示賬號

android:textColor="@color/white"/>【任務實現(xiàn)】

<EditText//用于賬號的輸入

android:id="@+id/editText1"android:layout_width="0.0dp"android:layout_weight="8"android:layout_height="wrap_content"android:ems="10"><requestFocus/></EditText></LinearLayout>【任務實現(xiàn)】

3)在第二個線性布局管理器中,繼續(xù)添加一個TextView控件和一個EditText控件,用于密碼的輸入,并添加一個CheckBox決定是否顯示密碼。代碼如下:<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="50dp"android:layout_marginRight="50dp"android:layout_marginTop="20dp">

<TextViewandroid:id="@+id/textView1"android:layout_width="0.0dp"android:layout_weight="2"android:layout_height="wrap_content"android:gravity="right"android:text="密碼:"http://顯示文本:密碼

android:textColor="@color/white"/>【任務實現(xiàn)】

<EditText//用于密碼的輸入

android:id="@+id/editText1"android:layout_height="wrap_content"android:layout_width="0.0dp"android:layout_weight="5"android:ems="10">

</EditText>//該復選框用于是否顯示密碼的勾選

<CheckBoxandroid:id="@+id/checkBox1"android:layout_width="0.0dp"android:layout_height="wrap_content"android:layout_weight="3"android:textColor="@color/white"android:text="顯示密碼"/>

</LinearLayout>【任務實現(xiàn)】

4)在第三個線性布局管理器中,繼續(xù)添加一個TextView控件和一個EditText控件,用于確認密碼的輸入。代碼如下:<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="50dp"android:layout_marginRight="50dp"android:layout_marginTop="20dp">

<TextViewandroid:id="@+id/textView1"android:layout_width="0.0dp"android:layout_weight="2"android:layout_height="wrap_content"android:gravity="right"android:text="確認密碼:"http://用于顯示文本:確認密碼【任務實現(xiàn)】

android:textColor="@color/white"/>//用于確認密碼的輸入

<EditTextandroid:id="@+id/editText1"android:layout_height="wrap_content"android:layout_width="0.0dp"android:layout_weight="8"android:ems="10"></EditText></LinearLayout>【任務實現(xiàn)】

5)在第四個線性布局管理器中,繼續(xù)添加一個RadioGroup控件,在RadioGroup控件中,添加兩個RadioButton按鈕,用于性別的選擇。代碼如下:<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="50dp"android:layout_marginTop="20dp"android:layout_marginRight="50dp">//RadioGroup與RadioButton組件配合使用

<RadioGroupandroid:id="@+id/radioGroup1"android:orientation="horizontal"android:gravity="right"android:layout_width="match_parent"android:layout_height="wrap_content">

<RadioButtonandroid:id="@+id/radio0"android:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true"http://默認選項為男【任務實現(xiàn)】

android:textColor="@color/white"android:layout_marginRight="40dp"android:text="男"/><RadioButtonandroid:id="@+id/radio1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="@color/white"android:text="女"/></RadioGroup></LinearLayout>【任務實現(xiàn)】

6)在外層的線性布局管理器中,添加一個CheckBox控件,用于同意注冊協(xié)議的選擇,以及一個Button按鈕,點擊按鈕,實現(xiàn)注冊功能。代碼如下:<

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論