日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

android用户界面-组件Widget-常用组件

發(fā)布時(shí)間:2025/3/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android用户界面-组件Widget-常用组件 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

用戶會(huì)員注冊(cè)實(shí)例

介紹控件

文本框TextView

編輯框EditText

密碼文本框EditText

單選按鈕RadioButton

復(fù)選框CheckBox

開關(guān)按鈕ToggleButton

下拉列表Spinner

實(shí)例:

注冊(cè)頁(yè)面

/Chapter04_UI_CommonWidget/src/com/amaker/test/MainActivity.java

?

  • 代碼 ?
  • ?
  • package?com.amaker.test; ?
  • ?
  • import?android.app.Activity; ?
  • import?android.content.Intent; ?
  • import?android.os.Bundle; ?
  • import?android.view.View; ?
  • import?android.view.View.OnClickListener; ?
  • import?android.widget.ArrayAdapter; ?
  • import?android.widget.Button; ?
  • import?android.widget.CheckBox; ?
  • import?android.widget.EditText; ?
  • import?android.widget.RadioButton; ?
  • import?android.widget.Spinner; ?
  • import?android.widget.ToggleButton; ?
  • ?
  • public?class?MainActivity?extends?Activity?{ ?
  • ???? ?
  • ????private?Button?register,cancel; ?
  • ????private?ToggleButton?marriged; ?
  • ????private?RadioButton?male,female; ?
  • ????private?EditText?username,password; ?
  • ????private?Spinner?position; ?
  • ????private?CheckBox?reading,swimming; ?
  • ???? ?
  • ????@Override?
  • ????public?void?onCreate(Bundle?savedInstanceState)?{ ?
  • ????????super.onCreate(savedInstanceState); ?
  • ????????setContentView(R.layout.main); ?
  • ???????? ?
  • ????????username?=?(EditText)findViewById(R.id.username); ?
  • ????????password?=?(EditText)findViewById(R.id.password); ?
  • ???????? ?
  • ????????male?=?(RadioButton)findViewById(R.id.male); ?
  • ????????female?=?(RadioButton)findViewById(R.id.female); ?
  • ???????? ?
  • ????????reading?=?(CheckBox)findViewById(R.id.reading); ?
  • ????????swimming?=?(CheckBox)findViewById(R.id.swimming); ?
  • ???????? ?
  • ????????marriged?=?(ToggleButton)findViewById(R.id.marriged); ?
  • ???????? ?
  • ????????position?=?(Spinner)findViewById(R.id.position); ?
  • ???????? ?
  • ????????String[]?str?=?{"CEO","CFO","PM"}; ?
  • ???????? ?
  • ????????ArrayAdapter?aa?=?new?ArrayAdapter(this,?android.R.layout.simple_spinner_dropdown_item,str); ?
  • ???????? ?
  • ????????position.setAdapter(aa); ?
  • ???????? ?
  • ????????register?=?(Button)findViewById(R.id.register); ?
  • ????????cancel?=?(Button)findViewById(R.id.cancel); ?
  • ???????? ?
  • ????????register.setOnClickListener(new?OnClickListener()?{ ?
  • ????????????public?void?onClick(View?v)?{ ?
  • ????????????????Bundle?b?=?new?Bundle(); ?
  • ????????????????b.putString("username",?"用戶名稱:"+username.getText().toString()); ?
  • ????????????????b.putString("password",?"用戶密碼:"+password.getText().toString()); ?
  • ???????????????? ?
  • ????????????????if(male.isChecked()){ ?
  • ????????????????????b.putString("gender",?"性別:男"); ?
  • ????????????????}else{ ?
  • ????????????????????b.putString("gender",?"性別:女"); ?
  • ????????????????} ?
  • ????????????????String?temp?=?"愛好:"; ?
  • ????????????????if(reading.isChecked()){ ?
  • ????????????????????temp+="閱讀"; ?
  • ????????????????} ?
  • ????????????????if(swimming.isChecked()){ ?
  • ????????????????????temp+="?"; ?
  • ????????????????????temp+="游泳"; ?
  • ????????????????} ?
  • ???????????????? ?
  • ????????????????b.putString("hobby",?temp); ?
  • ???????????????? ?
  • ????????????????if(marriged.isChecked()){ ?
  • ????????????????????b.putString("marriged",?"婚否:已婚"); ?
  • ????????????????}else{ ?
  • ????????????????????b.putString("marriged",?"婚否:未婚"); ?
  • ????????????????} ?
  • ???????????????? ?
  • ????????????????b.putString("position","職位:"+?position.getSelectedItem().toString()); ?
  • ???????????????? ?
  • ????????????????Intent?intent?=?new?Intent(MainActivity.this,ResultActivity.class); ?
  • ???????????????? ?
  • ????????????????intent.putExtra("data",?b); ?
  • ???????????????? ?
  • ????????????????startActivity(intent); ?
  • ????????????} ?
  • ????????}); ?
  • ???????? ?
  • ????} ?
  • }?
  • 注冊(cè)結(jié)果頁(yè)面

    /Chapter04_UI_CommonWidget/src/com/amaker/test/ResultActivity.java

    ?

  • 代碼 ?
  • ?
  • package?com.amaker.test; ?
  • ?
  • import?java.util.ArrayList; ?
  • import?java.util.List; ?
  • import?android.app.Activity; ?
  • import?android.content.Intent; ?
  • import?android.os.Bundle; ?
  • import?android.widget.ArrayAdapter; ?
  • import?android.widget.ListView; ?
  • ?
  • public?class?ResultActivity?extends?Activity{ ?
  • ????private?ListView?listView; ?
  • ???? ?
  • ????protected?void?onCreate(Bundle?savedInstanceState)?{ ?
  • ????????super.onCreate(savedInstanceState); ?
  • ???????? ?
  • ????????setContentView(R.layout.result); ?
  • ????????listView?=?(ListView)?findViewById(R.id.ListView01); ?
  • ???????? ?
  • ????????Intent?intent?=?this.getIntent(); ?
  • ???????? ?
  • ????????Bundle?b?=?intent.getBundleExtra("data"); ?
  • ???????? ?
  • ????????System.out.println(b.getString("username")); ?
  • ???????? ?
  • ????????List?list?=??new?ArrayList(); ?
  • ???????? ?
  • ????????list.add(b.getString("username")); ?
  • ????????list.add(b.getString("password")); ?
  • ????????list.add(b.getString("position")); ?
  • ???????? ?
  • ????????list.add(b.getString("gender")); ?
  • ????????list.add(b.getString("hobby")); ?
  • ????????list.add(b.getString("marriged")); ?
  • ???????? ?
  • ????????ArrayAdapter?adapter?=?new?ArrayAdapter(this,android.R.layout.simple_list_item_1,list); ?
  • ???????? ?
  • ????????listView.setAdapter(adapter); ?
  • ???????? ?
  • ????} ?
  • }?
  • 布局文件

    /Chapter04_UI_CommonWidget/res/layout/main.xml

    ?

  • 代碼 ?
  • ?
  • <?xml?version="1.0"?encoding="utf-8"?>?
  • <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"?
  • ????android:orientation="vertical"?
  • ????android:layout_width="fill_parent"?
  • ????android:layout_height="fill_parent"?
  • ????>?
  • ???? ?
  • ???? ?
  • ?
  • <TableLayout? ?
  • ????android:id="@+id/TableLayout01"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content"?
  • ????android:stretchColumns="1"?
  • ????>?
  • ???? ?
  • ???? ?
  • ????<TableRow? ?
  • ????android:id="@+id/TableRow01"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content">?
  • ????????<TextView? ?
  • ????????android:text="用戶名稱"? ?
  • ????????android:id="@+id/TextView01"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></TextView>?
  • ???????? ?
  • ????????<EditText? ?
  • ????????android:text=""? ?
  • ????????android:id="@+id/username"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"?
  • ???????? ?
  • ????????></EditText>?
  • ????</TableRow>?
  • ???? ?
  • ????<TableRow? ?
  • ????android:id="@+id/TableRow02"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content">?
  • ????????<TextView? ?
  • ????????android:text="用戶密碼"? ?
  • ????????android:id="@+id/TextView02"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></TextView>?
  • ???????? ?
  • ????????<EditText? ?
  • ????????android:text=""? ?
  • ????????android:id="@+id/password"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"?
  • ????????android:password="true"?
  • ???????? ?
  • ????????></EditText>?
  • ????</TableRow>?
  • ???? ?
  • ????<TableRow? ?
  • ????android:id="@+id/TableRow03"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content">?
  • ????????<TextView? ?
  • ????????android:text="性別"? ?
  • ????????android:id="@+id/TextView03"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></TextView>?
  • ???????? ?
  • ????????<RadioGroup? ?
  • ????????android:id="@+id/gender_g"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content">?
  • ???????? ?
  • ????????<RadioButton? ?
  • ????????android:text="男"? ?
  • ????????android:id="@+id/male"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></RadioButton>?
  • ???????? ?
  • ????????<RadioButton? ?
  • ????????android:text="女"? ?
  • ????????android:id="@+id/female"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></RadioButton>?
  • ???????? ?
  • ???????? ?
  • ????????</RadioGroup>?
  • ????</TableRow>?
  • ???? ?
  • ???? ?
  • ????<TableRow? ?
  • ????android:id="@+id/TableRow04"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content">?
  • ????????<TextView? ?
  • ????????android:text="婚否"? ?
  • ????????android:id="@+id/TextView04"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></TextView>?
  • ???????? ?
  • ???????? ?
  • ????<ToggleButton? ?
  • ????android:text="@+id/ToggleButton01"? ?
  • ????android:id="@+id/marriged"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content"></ToggleButton>?
  • </TableRow>?
  • ???? ?
  • ????<TableRow? ?
  • ????android:id="@+id/TableRow05"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content"?
  • ????>?
  • ????????<TextView? ?
  • ????????android:text="愛好"? ?
  • ????????android:id="@+id/hobby"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></TextView>?
  • ???????? ?
  • ????????<CheckBox? ?
  • ????????android:text="閱讀"? ?
  • ????????android:id="@+id/reading"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"?
  • ????????android:layout_column="1"?
  • ????????></CheckBox>?
  • ????????<CheckBox? ?
  • ????????android:text="游泳"? ?
  • ????????android:id="@+id/swimming"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"?
  • ????????android:layout_column="1"?
  • ????????></CheckBox>?
  • ???????? ?
  • ???????? ?
  • ????</TableRow>?
  • ???? ?
  • ???? ?
  • ????<TableRow? ?
  • ????android:id="@+id/TableRow06"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content">?
  • ????????<TextView? ?
  • ????????android:text="職務(wù)"? ?
  • ????????android:id="@+id/TextView05"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></TextView>?
  • ???????? ?
  • ????????<Spinner? ?
  • ????????android:id="@+id/position"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></Spinner>?
  • ????</TableRow>?
  • ???? ?
  • ???? ?
  • ????<TableRow? ?
  • ????android:id="@+id/TableRow07"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content">?
  • ????????<Button? ?
  • ????????android:text="取消"? ?
  • ????????android:id="@+id/cancel"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></Button>?
  • ???????? ?
  • ????????<Button? ?
  • ????????android:text="注冊(cè)"? ?
  • ????????android:id="@+id/register"? ?
  • ????????android:layout_width="wrap_content"? ?
  • ????????android:layout_height="wrap_content"></Button>?
  • ???????? ?
  • ????</TableRow>?
  • ???? ?
  • </TableLayout>?
  • </LinearLayout>?
  • /Chapter04_UI_CommonWidget/res/layout/result.xml

    ?

  • 代碼 ?
  • ?
  • <?xml?version="1.0"?encoding="utf-8"?>?
  • <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"?
  • ????android:orientation="vertical"?
  • ????android:layout_width="fill_parent"?
  • ????android:layout_height="fill_parent"?
  • ????>?
  • ????<ListView? ?
  • ????android:id="@+id/ListView01"? ?
  • ????android:layout_width="wrap_content"? ?
  • ????android:layout_height="wrap_content"></ListView>?
  • </LinearLayout>?
  • ?


    本文轉(zhuǎn)自linzheng 51CTO博客,原文鏈接:http://blog.51cto.com/linzheng/1080698

    總結(jié)

    以上是生活随笔為你收集整理的android用户界面-组件Widget-常用组件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 成人免费淫片aa视频免费 | 久久九| 一区二区 亚洲 | 激情久久网 | 少妇性bbb搡bbb爽爽爽欧美 | 国产精品99无码一区二区视频 | 欧美日本韩国一区二区 | 国产农村妇女精品一区二区 | 日本少妇xxxx软件 | 手机看片福利永久 | mm1313亚洲国产精品无码试看 | 激情五月婷婷色 | 麻豆成人久久精品一区二区三区 | 欧美mv日韩mv国产网站app | 美女脱裤子打屁股 | 欧美肥妇bwbwbwbxx | 中文不卡在线 | 久久久久亚洲av片无码下载蜜桃 | 亚洲一区二区观看播放 | 国产91九色| 五月婷婷狠狠干 | 亚洲av人人澡人人爽人人夜夜 | 国产一区二区三区免费观看 | 777中文字幕 | 亚洲欧美第一 | 中文字幕国产一区 | 高清国产午夜精品久久久久久 | 五月天婷婷网站 | 9人人澡人人爽人人精品 | 一级片在线免费播放 | 91大神精品 | 97caoporn| 涩涩视屏 | 蜜臀一区二区三区精品免费视频 | 日韩簧片 | 国产一区二区精品在线观看 | 亚洲欧洲日韩综合 | 欧美中文字幕一区二区 | 国产嘿咻视频 | 西西久久 | 高柳家在线观看 | 欧美精品v国产精品v日韩精品 | 亚洲日日日 | 亚洲人性生活视频 | 日本一区二区在线不卡 | 东方av正在进入 | 视色av| 麻豆影视大全 | 午夜影院日本 | 亚洲成人1区 | 日本公妇乱偷中文字幕 | 在线不卡欧美 | 超碰98在线观看 | 精品国产三级a∨在线 | 欧美另类videosbestsex | 国产午夜一级片 | 日本a在线观看 | 国产在线播放网站 | 美女网站免费观看视频 | 中文字幕日韩在线视频 | 在线视频区 | 黑人av| 欧洲亚洲一区二区 | 深夜福利视频网站 | 性做久久久久久久 | 中文字幕一区三区 | av男人资源 | 亚洲中文字幕一区二区 | 少妇三级全黄 | 天天尻 | 成人区精品一区二区婷婷 | 法国空姐在线观看完整版 | 高潮流白浆在线观看 | 人人妻人人澡人人爽精品 | 久久中文字幕高清 | 欧美一区二区最爽乱淫视频免费看 | 三级黄色免费网站 | 成人永久视频 | 激情婷婷网 | 999视频在线播放 | 日韩一区二区三区免费在线观看 | 打开免费观看视频在线 | 双性人bbww欧美双性 | 欧美成人精品 | 毛片随便看 | 精品一区二区三区免费观看 | av日韩一区 | 人成在线观看 | 色综合久久久久无码专区 | 男人插入女人阴道视频 | 黄色伊人| 狠狠人妻久久久久久综合蜜桃 | 天天躁夜夜操 | 假日游船 | 6080福利| av小说免费在线观看 | 日操干 | 日韩视频在线一区 | 神马午夜激情 |