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

歡迎訪問(wèn) 生活随笔!

生活随笔

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

编程问答

【安卓3】基本控件

發(fā)布時(shí)間:2024/6/21 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【安卓3】基本控件 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Activity用于存放各個(gè)顯示控件,是Android的基本組成

Activity常用方法:

Activity類常用方法

方法

描述

view findViewById ( int id )

根據(jù)組件的id取得組件對(duì)象

setEnabled(boolean enabled)

設(shè)置是否可編輯

setFocusable(boolean focusable)

設(shè)置是否默認(rèn)取得焦點(diǎn)

setProgress(int progress)

設(shè)置ProgressBar的進(jìn)度

setSecondaryProgress(int secondaryProgress)

設(shè)置第二進(jìn)度條的進(jìn)度

Window getWindow()

取得一個(gè)Window對(duì)象

setContendView ( int ?layoutResId )

設(shè)置布局文件,設(shè)置顯示文件

setContendView (View view )

設(shè)置顯示組件

?

配置屬性名稱

對(duì)應(yīng)方法

描述

android: text

public final void setText(CharSequence text)

定義組件的顯示文字

android: maxLength

public void setFilter(InputFilter[] filters)

設(shè)置組件最大允許長(zhǎng)度

android: textColor

public void setTextColor(ColorStateList colors)

設(shè)置組件的文本顏色

android: textSize

public void setTextSize(float size)

設(shè)置顯示的文字大小

android: textStyle

?

設(shè)置文字顯示的樣式、粗體、斜體等

android: selectAllOnFocus

public void setAllOnFocus (boolean setAllOnFocus)

默認(rèn)選中并獲得焦點(diǎn)

android: password

public final void setTransformationMethod

(TransformationMethod method)

按密文方式顯示文本信息

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

?

設(shè)置字體風(fēng)格和大小

?????? (android: textStyle)——》{正常(normal)、粗體(bold)、斜體(italic)}

?????? 字體大小的單位:

? ? ? ? ? ? ? px(像素)、dip(依賴于設(shè)備的像素)、sp(帶比例的像素)、pt(點(diǎn))、in(英尺)、mm(毫米)

?

?????? android: id= ” @id/id值”?????????????? ?????? ?????? //設(shè)置id值

?????? android: text=”**” ???????????????? ?????? ?????? ?????? //定義顯示文字

? ? ? ? android: layout_width="wrap_content" ???? //組件寬度為文字寬度

?????? android: layout_height="wrap_content"????? //組件寬度為文字高度

TextView(文本顯示框)

?????? android: maxLength=”6” ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//允許最大字符數(shù)

?????? android: textColor=”#0FF00” ? ? ? ? ? ? ? ? ? ? ? ?//文字顏色

?????? android: textSize=”50px” ? ? ? ? ? ? ? ? ? ? ? ? ? ? //文字大小

?????? android: textStyle=”bold” ? ? ? ? ? ? ? ? ? ? ? ? ? ? //文字樣式

?????? android: password=”true” ? ? ? ? ? ? ? ? ? ? ? ? ? ?//是否以密文方式顯示

?????? android: layout_margin=”10px” ? ? ? ? ? ? ? ? ? ?//外邊距

?????? android: backgroud=”@drawable/圖片名稱” ? ? //背景

?????? getText().toString()?? ??????????????????????????? //獲得控件的文本內(nèi)容

?????? setText()????????????????????????????????????????? //設(shè)置控件的文本內(nèi)容

Button (按鈕)

EditText(編輯框)

???????? android: password=””????????????? ????//是否以密文方式顯示

?????? android: numeric=”integer”?????????? ??//只能輸入數(shù)字

?????? android: hint=”**”??????????? ?????? ??????//水印

?????? android: enabled=”false”??????? ????? ??//設(shè)置是否可用,false不能用

RadioButton(單選按鈕)

?????? 嵌入到RadioGroup中實(shí)現(xiàn)單選效果

???????? android: checkedButton=”radio的id值 ”;

?????? int getCheckedRadioButtonId( );?????????? //獲得被選中的單選按鈕的id

CheckBox(復(fù)選框)

???????? android: checked=”true”;??????? ?????? //設(shè)置默認(rèn)選中

???????? CheckBox(Context context)??????????? ?//實(shí)例化CheckBox組件

?????? void setChecked(boolean checked)? ??? //設(shè)置默認(rèn)選中

ImageView(圖片)

?????? android: maxHeight=” ”;???????? ?????? //定義圖片的最大高度

?????? android: maxWidth=” ”;????????? ?????? //定義圖片的最大寬度

?????? android: src=” ”;??????? ?????? ????????????//定義顯示圖片的ID

ImageButton(圖片按鈕)

?

*重復(fù)屬性省略*

轉(zhuǎn)載于:https://www.cnblogs.com/leelee/p/6860435.html

總結(jié)

以上是生活随笔為你收集整理的【安卓3】基本控件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

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