freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

第5章android用戶界面(參考版)

2025-07-23 11:28本頁面
  

【正文】 菜單 ? 子菜單 ? 第 1行代碼在 onCreateOptionsMenu()函數(shù)傳遞的 menu對象上調用 addSubMenu()函數(shù),在選項菜單中添加一個菜單子項,用戶點擊后可以打。 4. (0,SUB_MENU_UPLOAD_A,0,上傳參數(shù) A)。 2. ()。 10. } 11. return false。 7. case MENU_UPLOAD: 8. MenuUploadCounter++。 7. } 菜單 ? 選項菜單 ? onOptionsItemSelected ()函數(shù)能夠處理 菜單選擇事件, 且該函數(shù)在每次點擊菜單子項時都會被調用 ? 下面的代碼說明了如何通過菜單子項的子項 ID執(zhí)行不同的操作 1. Override 2. public boolean onOptionsItemSelected(MenuItem item){ 3. switch(()){ 4. case MENU_DOWNLOAD: 5. MenuDownlaodCounter++。 5. (上傳設置 : +(MenuUploadCounter))。 菜單 ? 選項菜單 ? 重載 onPrepareOptionsMenu()函數(shù) , 能夠動態(tài)的添加、刪除菜單子項,或修改菜單的標題、圖標和可見性等內容 ? onPrepareOptionsMenu()函數(shù)的返回值的含義與onCreateOptionsMenu()函數(shù)相同 ? 返回 true則顯示菜單 ? 返回 false則不顯示菜單 菜單 ? 選項菜單 ? 下面的代碼是在用戶每次打開選項菜單時,在菜單子項中顯示用戶打開該子項的次數(shù) ? 第 1行代碼設置一個菜單子項的計數(shù)器,用來統(tǒng)計用戶打開“上傳設置”子項的次數(shù) ? 第 4行 代碼是 通過將菜單子項的 ID傳遞給 ()函數(shù),獲取到菜單子項的對象 ? 第 5行 代碼是 通過 MenuItem的 setTitle()函數(shù)修改菜單標題 1. static int MenuUploadCounter = 0。 8. } 菜單 ? 選項菜單 ? 第 4行 代碼 Menu對象作為一個參數(shù)被傳遞到函數(shù)內部,因此在 onCreateOptionsMenu()函數(shù)中,用戶可以使用Menu對象的 add()函數(shù)添加菜單子項 ? add()函數(shù)的語法 ? 第 1個參數(shù) groupId是組 ID,用以批量的對菜單子項進行處理和排序 ? 第 2關參數(shù) itemId是子項 ID,是每一個菜單子項的唯一標識,通過子項 ID使應用程序能夠定位到用戶所選擇的菜單子項 ? 第 3個參數(shù) order是定義菜單子項在選項菜單中的排列順序 ? 第 4個參數(shù) title是菜單子項所顯示的標題 MenuItem (int groupId, int itemId, int order, CharSequence title) 菜單 ? 選項菜單 ? 添加菜單子項的圖標和快捷鍵:使用 setIcon()函數(shù)和setShortcut()函數(shù) ? MENU_DOWNLOAD菜單設置圖標和快捷鍵的代碼 ? 第 2行代碼中使用了新的圖像資源,用戶將需要使用的圖像文件拷貝到 /res/drawable目錄下 ? setShortcut()函數(shù)第一個參數(shù)是為數(shù)字鍵盤設定的快捷鍵 ? 第二個參數(shù)是為全鍵盤設定的快捷鍵,且不區(qū)分字母的大小寫 1. (0,MENU_DOWNLOAD,0,下載設置 ) 2. .setIcon()。 6. (0,MENU_UPLOAD,1,上傳設置 )。 2. final static int MENU_UPLOAD = +1。其中, Id屬性分別為 TableRow01和TableRow02, Layout width和 Layout height屬性都為wrap_content 界面布局 ? 表格布局 ? 通過 Outline,向 TableRow01中添加 TextView和 EditText 界面布局 ? 表格布局 ? 通過 Outline,向TableRow02中添加兩個 Button ? 參考 下 表設置TableRow中四個界面控件的屬性值 編號 類型 屬性 值 1 TextView Id +id/label Text 用戶名: Gravity right Padding 3dip Layout width 160dip 2 EditText Id +id/entry Text [null] Padding 3dip Layout width 160dip 3 Button Id +id/ok Text 確認 Padding 3dip 4 Button Id +id/cancel Text 取消 Padding 3dip 界面布局 ? 表格布局 ? 1. ?xml version= encoding=utf8? 2. 3. TableLayout android:id=+id/TableLayout01 4. android:layout_width=fill_parent 5. android:layout_height=fill_parent 6. xmlns:android= 7. TableRow android:id=+id/TableRow01 8. android:layout_width=wrap_content 9. android:layout_height=wrap_content 10. TextView android:id=+id/label 11. android:layout_height=wrap_content 12. android:layout_width=160dip 13. android:gravity=right 14. android:text=用戶名: 15. android:padding=3dip 16. /TextView 界面布局 ? 表格布局 17. EditText android:id=+id/entry 18. android:layout_height=wrap_content 19. android:layout_width=160dip“ 20. android:padding=3dip 21. /EditText 22. /TableRow 23. TableRow android:id=+id/TableRow02 24. android:layout_width=wrap_content 25. android:layout_height=wrap_content 26. Button android:id=+id/ok 27. android:layout_height=wrap_content 28. android:padding=3dip 29. android:text=確認 30. /Button 界面布局 ? 表格布局 ? 第 3行代碼使用了 TableLayout標簽聲明表格布局 ? 第 7行和第 23行代碼聲明了兩個 TableRow元素 ? 第 12行 設定 寬度屬性 android:layout_width: 160dip ? 第 13行 設定 屬性 android:gravity,指定文字為右對齊 ? 第 15行使用屬性 android:padding,聲明 TextView元素與其他元素的間隔距離為 3dip 31. Button android:id=+id/Button02 32. android:layout_width=wrap_content 33. android:layout_height=wrap_content 34. android:padding=3dip 35. android:text=取消 36. /Button 37. /TableRow 38. /TableLayout 界面布局 ? 相對布局 ? 相對布局( RelativeLayout)是一種非常靈活的布局方式,能夠通過指定界面元素與其他元素的相對位置關系,確定界面中所有元素的布局位置 ? 特點: 能夠最大程度保證在各種屏幕類型的手機上正確顯示界面布局 界面布局 ? 相對布局 ? 相對布局示例說明 ? 添加 TextView控件(“用戶名”),相對布局會將TextView控件放置在屏幕的最上方 ? 然后添加 EditText控件(輸入框),并聲明該控件的位置在 TextView控件的下方,相對布局會根據(jù) TextView的位置確定 EditText控件的位置 ? 之后添加第一個 Button控件(“取消”按鈕),聲明在EditText控件的下方,且在父控件的最右邊 ? 最后,添加第二個 Button控件(“確認”按鈕),聲明該控件在第一個 Button控件的左方,且與第一個 Button控件處于相同的水平位置 界面布局 ? 相對布局 ? 相對布局在 1. ?xml version= encoding=utf8? 2. 3. RelativeLayout android:id=+id/RelativeLayout01 4. android:layout_width=fill_parent 5. android:layout_height=fill_parent 6. xmlns:android= 7. TextView android:id=+id/label 8. android:layout_height=wrap_content 9. android:layout_width=fill_parent 10. android:text=用戶名: 11. /TextView 12. EditText android:id=+id/entry 13. android:layout_height=wrap_content 14. android:layout_width=fill_parent 15. android:layout_below=id/label 16. /EditText 界面布局 ? 相對布局 17. Button android:id=+id/cancel 18. android:layout_height=wrap_content 19. android:layout_width=wrap_content 20. android:layout_alignParentRight=true 21. android:layout_marginLeft=10dip 22. android:layout_below=id/entry 23. android:text=取消 24. /Button 25. Button android:id=+id/ok 26. android:layout_height=wrap_content 27. android:layout_width=wrap_content 28. android:layout_toLeftOf=id/cancel 29. android:layout_alignTop=id/cancel“ 30. android:text=“確認 ”、 31. /Button 32. /RelativeLayout 界面布局 ? 相對布局 ? 第 3行使用了 RelativeLayout標簽聲明一個相對布局 ? 第 15行使用位置屬性 android:layout_below,確定EditText控件在 ID為 label的元素下方 ? 第 20行使用屬性 android:layout_alignParentRight,聲明該元素在其父元素的右邊邊
點擊復制文檔內容
語文相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1