最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)密碼隱藏和顯示

 更新時(shí)間:2022年08月02日 11:24:40   作者:Swift社區(qū)  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)密碼隱藏和顯示,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)密碼隱藏和顯示的具體代碼,供大家參考,具體內(nèi)容如下

在Android開發(fā)中,需要密碼的隱藏和顯示,下面就和大家分享一下使用方法:

xml代碼:

<LinearLayout?
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="50dp"
? ? ? ? ? ? android:background="@color/white"
? ? ? ? ? ? android:orientation="horizontal" >

? ? ? ? ? ? <TextView
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="match_parent"
? ? ? ? ? ? ? ? android:text="新密碼"
? ? ? ? ? ? ? ? android:textColor="@color/black"
? ? ? ? ? ? ? ? android:textSize="18dp"
? ? ? ? ? ? ? ? android:gravity="center_vertical"
? ? ? ? ? ? ? ? android:layout_marginLeft="15dp"/>

? ? ? ? ? ? <EditText
? ? ? ? ? ? ? ? android:id="@+id/newpassword"
? ? ? ? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:layout_height="match_parent"
? ? ? ? ? ? ? ? android:layout_gravity="center_vertical"
? ? ? ? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? ? ? ? android:inputType="textPassword"
? ? ? ? ? ? ? ? android:hint="請(qǐng)?jiān)O(shè)置登錄密碼"
? ? ? ? ? ? ? ? android:background="@null"/>

? ? ? ? ? ? <CheckBox
? ? ? ? ? ? ? ? android:id="@+id/CheckBox"
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="match_parent"
? ? ? ? ? ? ? ? android:layout_marginRight="15dp"
? ? ? ? ? ? ? ? android:textSize="16dp"
? ? ? ? ? ? ? ? android:text="顯示"
? ? ? ? ? ? ? ? />

</LinearLayout>

####隱藏圖標(biāo)代碼

android:button="@null"

JAVA代碼:

/**
?* Created by fby on 2017/9/11.
?*/

public class ChargepsdActivity extends Activity {

? ? private EditText editText;
? ? private CheckBox checkBox;

? ? @Override
? ? protected void onCreate(@Nullable Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_chargepsd);

? ? ? ? editText = (EditText) findViewById(R.id.newpassword);
? ? ? ? checkBox = (CheckBox) findViewById(R.id.CheckBox);

? ? ? ? checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

? ? ? ? ? ? ? ? if(isChecked){
? ? ? ? ? ? ? ? ? ? //如果選中,顯示密碼
? ? ? ? ? ? ? ? ? ? editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? //否則隱藏密碼
? ? ? ? ? ? ? ? ? ? editText.setTransformationMethod(PasswordTransformationMethod.getInstance());

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }
? ? ? ? });

? ? }
}

效果展示:

Android開發(fā)~獲取驗(yàn)證碼倒計(jì)時(shí)實(shí)現(xiàn)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

元阳县| 淄博市| 乌鲁木齐县| 苏州市| 瑞金市| 宜丰县| 靖安县| 故城县| 荣成市| 贵定县| 辉县市| 深圳市| 秭归县| 桑植县| 咸宁市| 尚志市| 通辽市| 渭南市| 沂水县| 嘉义市| 元朗区| 富民县| 东辽县| 革吉县| 定日县| 库车县| 嘉义市| 泰安市| 绥芬河市| 桃园县| 蒲城县| 锡林郭勒盟| 泽库县| 泸州市| 临西县| 临朐县| 香格里拉县| 北宁市| 会昌县| 隆安县| 宜良县|