国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android 密碼 顯示與隱藏功能實例

2019-12-12 02:41:14
字體:
供稿:網(wǎng)友

效果:

<?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/editText1"  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:ems="10"  android:inputType="textPassword" >  <requestFocus /> </EditText> <CheckBox  android:id="@+id/checkBox1"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="顯示密碼" /></LinearLayout>
package com.example.test;import android.app.Activity;import android.os.Bundle;import android.text.method.HideReturnsTransformationMethod;import android.text.method.PasswordTransformationMethod;import android.widget.CheckBox;import android.widget.CompoundButton;import android.widget.CompoundButton.OnCheckedChangeListener;import android.widget.TextView;public class MainActivity extends Activity {private TextView editText1;private CheckBox checkBox1; @Override protected void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentView(R.layout.test);  editText1 =(TextView) findViewById(R.id.editText1);  checkBox1=(CheckBox) findViewById(R.id.checkBox1);  checkBox1.setOnCheckedChangeListener(new OnCheckedChangeListener() {   @Override   public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {    // TODO Auto-generated method stub    if(isChecked){     //如果選中,顯示密碼       editText1.setTransformationMethod(HideReturnsTransformationMethod.getInstance());    }else{     //否則隱藏密碼     editText1.setTransformationMethod(PasswordTransformationMethod.getInstance());    }   }  }); }}

關(guān)鍵是:

editText1.setTransformationMethod(HideReturnsTransformationMethod.getInstance());editText1.setTransformationMethod(PasswordTransformationMethod.getInstance());

以上所述是小編給大家介紹的Android 密碼 顯示與隱藏功能實例,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 普格县| 上杭县| 于都县| 娄烦县| 天长市| 东光县| 浦江县| 宕昌县| 盐边县| 九龙县| 大悟县| 永济市| 新平| 集贤县| 天长市| 长宁县| 饶平县| 温宿县| 鄂温| 浮梁县| 壤塘县| 宝坻区| 福海县| 宜州市| 甘南县| 青铜峡市| 曲阜市| 宾阳县| 高安市| 新沂市| 北川| 丰都县| 顺平县| 米易县| 内江市| 安仁县| 东山县| 蕉岭县| 永善县| 镇巴县| 江口县|