<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      EditText 基本用法

      EditText介紹:

      EditText 在開發中也是經常用到的控件,也是一個比較必要的組件,可以說它是用戶跟Android應用進行數據傳輸的窗戶,比如實現一個登陸界面,需要用戶輸入賬號密碼,然后我們獲取用戶輸入的內容,提交給服務器進行判斷。

      EditText 支持的 XML 屬性及相關方法

      XML 屬性 相關方法 說明
      android:text setText(CharSequence text) 設置文本內容
      android:textColor setTextColor(int color) 字體顏色
      android:hint setHint(int resid) 內容為空時候顯示的文本
      android:textColorHint void setHintTextColor(int color) 為空時顯示的文本的顏色
      android:inputType setInputType(int type) 限制輸入類型
      number:整數類型
      numberDecimal:小數點類型
      date:日期類型
      text:文本類型(默認值)
      phone:撥號鍵盤
      textPassword:密碼
      textVisiblePassword:可見密碼
      textUri:網址
      android:maxLength 限制顯示的文本長度,超出部分不顯示
      android:minLines setMaxLines(int maxlines) 設置文本的最小行數
      android:gravity setGravity(int gravity) 設置文本位置,如設置成“center”,文本將居中顯示。
      android:drawableLeft setCompoundDrawables(Drawable left,Drawable top,Drawable right, Drawable bottom) 在text的左邊輸出一個drawable,如圖片
      android:drawablePadding 設置text與drawable(圖片)的間隔,與drawableLeft、drawableRight、drawableTop、drawableBottom一起使用,可設置為負數,單獨使用沒有效果。
      android:digits 設置允許輸入哪些字符。如“1234567890”
      android:ellipsize 設置當文字過長時,該控件該如何顯示。
      start:省略號顯示在開頭
      end:省略號顯示在結尾
      middle:省略號顯示在中間
      marquee:以跑馬燈的方式顯示(動畫橫向移動)
      android:lines setLines(int lines) 設置文本的行數,設置兩行就顯示兩行,即使第二行沒有數據。
      android:lineSpacingExtra 設置行間距
      android:singleLine setSingleLine() true:單行顯示 false:可以多行
      android:textStyle 設置字形,可以設置一個或多個,用"|"隔開
      bold:粗體
      italic:斜體
      bolditalic:又粗又斜

      EditText實例:開發中常用的登錄界面

      首先我們來看布局文件:activity_main.xml

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical">
      
          <EditText
              android:id="@+id/et_phone"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="20dp"
              android:layout_marginRight="20dp"
              android:background="@null"
              android:inputType="number"
              android:maxLength="11"
              android:hint="請輸入手機號"
              android:drawablePadding="10dp"
              android:padding="10dp"
              android:drawableLeft="@mipmap/icon_phone"
              android:drawableBottom="@drawable/shape_et_bottom_line"
              android:layout_marginTop="20dp"/>
      
          <EditText
              android:id="@+id/et_password"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="20dp"
              android:layout_marginRight="20dp"
              android:layout_marginTop="10dp"
              android:background="@null"
              android:inputType="textPassword"
              android:maxLength="16"
              android:padding="10dp"
              android:drawablePadding="10dp"
              android:hint="請輸入密碼"
              android:drawableBottom="@drawable/shape_et_bottom_line"
              android:drawableLeft="@mipmap/icon_password"/>
      
          <TextView
              android:id="@+id/tv_login"
              style="@style/Widget.AppCompat.Button.Colored"
              android:layout_width="match_parent"
              android:layout_height="50dp"
              android:layout_marginLeft="10dp"
              android:layout_marginRight="10dp"
              android:layout_marginTop="30dp"
              android:text="登 錄"
              android:textColor="#ffffffff"
              android:textSize="18sp" />
      </LinearLayout>
      

      運行效果圖如下:
      帶有EditeText的登錄界面

      這兩個輸入框的用的的大部分屬性都在上面的表格中了,我這里解決下沒有說過的屬性。
      android:background="@null" 輸入框無背景
      android:drawableBottom="@drawable/shape_et_bottom_line" 底部引入一個shape布局文件,這個布局文件就是輸入框的下劃線。
      shape_et_bottom_line.xml內容如下:

      <shape xmlns:android="http://schemas.android.com/apk/res/android"
          android:shape="rectangle" >
      
          <solid android:color="#1E7EE3" />
          <size android:height="1dp" android:width="500dp"/>
      
      </shape>
      

      EditeText還有哪些功能?

      1.監聽用戶輸入的內容.
      有這樣一個場景,一個搜索框,只要用戶輸入了內容就去請求服務器,于是我們在Activity里面監聽EditeText文本改變事件。

      EditText etOne= (EditText) findViewById(R.id.et_phone);
      etOne.addTextChangedListener(new TextWatcher() {
                  @Override
                  public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                      Log.i("Ansen","內容改變之前調用:"+s);
                  }
      
                  @Override
                  public void onTextChanged(CharSequence s, int start, int before, int count) {
                      Log.i("Ansen","內容改變,可以去告訴服務器:"+s);
                  }
      
                  @Override
                  public void afterTextChanged(Editable s) {
                      Log.i("Ansen","內容改變之后調用:"+s);
                  }
       });
      

      首先我們通過id找到EditText控件,并且添加監聽函數,內部內實現TextWatcher接口,重寫三個方法。我們可以在onTextChanged方法中告訴服務器我要搜索的內容。

      源碼下載

      點擊下載源碼

      各位看官如果覺得文章不錯,幫忙點個贊吧,對于你來說是舉手之勞,但對于我來說這就是堅持下去的動力。

      如果你想第一時間看我們的后期文章,掃碼關注公眾號,每周不定期推送Android開發實戰教程文章,你還等什么,趕快關注吧,學好技術,出任ceo,贏取白富美。。。。

            Android開發666 - 安卓開發技術分享
                  掃描二維碼加關注
      

      Android開發666

      posted @ 2016-08-18 20:19  安輝  閱讀(44081)  評論(1)    收藏  舉報
      主站蜘蛛池模板: 日韩精品一区二区三区日韩| 久久久久久综合网天天| 久久精品国产99久久无毒不卡| 亚洲高清国产成人精品久久| 99在线精品国自产拍中文字幕| 少妇午夜福利一区二区三区| 好紧好爽午夜视频| 视频专区熟女人妻第二页| 遂川县| 一区二区三区在线色视频| 狠狠色噜噜狠狠狠狠777米奇| 国产精品二区中文字幕| 中文字幕色av一区二区三区| 家庭乱码伦区中文字幕在线| 一区二区三区四区亚洲自拍| 波多野结衣av高清一区二区三区| 国产成人精品性色av麻豆| 熟女一区二区中文字幕| 中文字幕人妻不卡精品| 思思久99久女女精品| 国产一区二区日韩在线| 国产熟妇久久777777| 国产人妇三级视频在线观看| 亚洲一区二区三区在线观看播放| 性动态图无遮挡试看30秒| 日韩精品福利视频在线观看| 69精品丰满人妻无码视频a片| 国产精品视频午夜福利| 色综合久久综合中文综合网| 国产成人女人在线观看| 国产成人久久精品流白浆| 又污又爽又黄的网站| 亚洲中文无码永久免费| 国产无套乱子伦精彩是白视频| 播放灌醉水嫩大学生国内精品| 伊伊人成亚洲综合人网7777| 亚洲综合无码明星蕉在线视频| 久久精品国产99国产精品澳门| 欧美牲交a欧美牲交aⅴ图片 | 粉嫩国产一区二区三区在线| 日韩av裸体在线播放|