欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android實(shí)現(xiàn)動態(tài)顯示或隱藏密碼輸入框的內(nèi)容

 更新時間:2014年09月04日 11:35:01   投稿:shichen2014  
這篇文章主要介紹了Android實(shí)現(xiàn)動態(tài)顯示或隱藏密碼輸入框的內(nèi)容,主要通過設(shè)置EditText的setTransformationMethod()方法來實(shí)現(xiàn),需要的朋友可以參考下

本文實(shí)例展示了Android實(shí)現(xiàn)動態(tài)顯示或隱藏密碼輸入框內(nèi)容的方法,分享給大家供大家參考之用。具體方法如下:

該功能可通過設(shè)置EditText的setTransformationMethod()方法來實(shí)現(xiàn)隱藏密碼或者顯示密碼。

示例代碼如下:

private Button mBtnPassword;
private EditText mEtPassword;
private boolean mbDisplayFlg = false;
 
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  mEtPassword = (EditText)findViewById(R.id.password);
  mBtnPassword = (Button)findViewById(R.id.btnPassword);
  mBtnPassword.setOnClickListener(new OnClickListener() {

 @Override
 public void onClick(View v) {
 // TODO Auto-generated method stub
 Log.d("AndroidTest", "mbDisplayFlg = " + mbDisplayFlg);
 if (!mbDisplayFlg) {
  // display password text, for example "123456"
  mEtPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
 } else {
  // hide password, display "."
  mEtPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
 }
 mbDisplayFlg = !mbDisplayFlg;
 mEtPassword.postInvalidate();
 }
  });
}

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">
 <Button android:id="@+id/btnPassword"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="密碼" />
 <EditText android:id="@+id/password"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:password="true"
 android:textSize="18sp"
 android:text="123456">
 </EditText>
</LinearLayout>

希望本文所述對大家的Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • Android View移動的3種方式總結(jié)

    Android View移動的3種方式總結(jié)

    這篇文章主要給大家介紹了Android View移動的三種方式,在介紹這三種方式之前先介紹了Android坐標(biāo)系的定義規(guī)則以及View的一些位置參數(shù)。有需要的朋友們可以參考借鑒。
    2016-09-09
  • Android Dialog對話框用法實(shí)例詳解

    Android Dialog對話框用法實(shí)例詳解

    這篇文章主要介紹了Android Dialog對話框用法,結(jié)合實(shí)例形式分析了Android使用Dialog對話框過程中所涉及的創(chuàng)建、保存、回復(fù)等操作相關(guān)技巧與注意事項(xiàng),需要的朋友可以參考下
    2016-07-07
  • 自定義RadioButton和ViewPager實(shí)現(xiàn)TabHost帶滑動的頁卡效果

    自定義RadioButton和ViewPager實(shí)現(xiàn)TabHost帶滑動的頁卡效果

    在工作中又很多需求都不是android系統(tǒng)自帶的控件可以達(dá)到效果的所以這個時候就要自定義控件來達(dá)到效果:使用自定義RadioButton和ViewPager實(shí)現(xiàn)TabHost帶滑動的頁卡效果
    2013-01-01
  • Android開發(fā)手機(jī)無線調(diào)試的方法

    Android開發(fā)手機(jī)無線調(diào)試的方法

    今天小編就為大家分享一篇關(guān)于Android開發(fā)手機(jī)無線調(diào)試的方法,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-12-12
  • 關(guān)于Android實(shí)現(xiàn)簡單的微信朋友圈分享功能

    關(guān)于Android實(shí)現(xiàn)簡單的微信朋友圈分享功能

    這篇文章主要介紹了關(guān)于Android實(shí)現(xiàn)簡單的微信朋友圈分享功能,非常不錯,具有參考借鑒價值,需要的的朋友參考下
    2017-02-02
  • Kotlin封裝RecyclerView Adapter實(shí)例教程

    Kotlin封裝RecyclerView Adapter實(shí)例教程

    這篇文章主要給大家介紹了關(guān)于Kotlin封裝RecyclerView Adapter的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-08-08
  • Android開發(fā)小技巧篇之集合

    Android開發(fā)小技巧篇之集合

    這篇文章主要介紹了Android開發(fā)-小技巧篇(集合) 的相關(guān)資料,需要的朋友可以參考下
    2016-01-01
  • Android多渠道打包的方法步驟

    Android多渠道打包的方法步驟

    本篇文章主要介紹了Android多渠道打包的方法步驟,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-10-10
  • 詳解Android JetPack之LiveData的工作原理

    詳解Android JetPack之LiveData的工作原理

    這篇文章主要介紹了詳解Android JetPack之LiveData的工作原理,幫助大家更好的理解和學(xué)習(xí)使用Android開發(fā),感興趣的朋友可以了解下
    2021-03-03
  • 詳解用flutter制作上班摸魚應(yīng)用

    詳解用flutter制作上班摸魚應(yīng)用

    本文主要介紹了用flutter制作上班摸魚應(yīng)用,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03

最新評論