久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

編輯文本密碼切換 Android

Edit text Password Toggle Android(編輯文本密碼切換 Android)
本文介紹了編輯文本密碼切換 Android的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我試圖在輸入類型為文本密碼的編輯文本中向用戶顯示輸入的密碼.

我在這樣的切換圖標(biāo)上實現(xiàn)了手勢監(jiān)聽器-

public boolean onTouch(View view, MotionEvent motionEvent) {開關(guān)(view.getId()){案例 R.id.ivPasswordToggle:開關(guān)(motionEvent.getAction()){案例 MotionEvent.ACTION_DOWN:Toast.makeText(getContext(),"show",Toast.LENGTH_SHORT).show();etPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);休息;案例 MotionEvent.ACTION_UP:etPassword.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);Toast.makeText(getContext(),"hide",Toast.LENGTH_SHORT).show();休息;}休息;}返回真;}

我不知道是什么問題,任何幫助將不勝感激.

解決方案

(針對AndroidX更新)

自支持庫 v24.2.0 起.你可以很容易地做到這一點

你需要做的只是:

  1. 將設(shè)計庫添加到您的依賴項中

     依賴項 {實現(xiàn)com.google.android.material:material:1.2.1"}

  2. TextInputEditTextTextInputLayout

    結(jié)合使用

     <com.google.android.material.textfield.TextInputLayoutxmlns:app=http://schemas.android.com/apk/res-auto"android:id=@+id/etPasswordLayout"android:layout_width=match_parent"android:layout_height="wrap_content";app:passwordToggleEnabled="true">

    I am trying to show user the typed password in edit text whose input type is text Password.

    I implemented gesturelistener over the toggle icon like this-

    public boolean onTouch(View view, MotionEvent motionEvent) {
            switch (view.getId())
            {
                case R.id.ivPasswordToggle:
    
                    switch ( motionEvent.getAction() ) {
                        case MotionEvent.ACTION_DOWN:
                            Toast.makeText(getContext(),"show",Toast.LENGTH_SHORT).show();
                            etPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                            break;
                        case MotionEvent.ACTION_UP:
                            etPassword.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);
                            Toast.makeText(getContext(),"hide",Toast.LENGTH_SHORT).show();
                            break;
                    }
                    break;
            }
            return true;
        }
    

    i dont know what is wrong, any help will be appreciated.

    解決方案

    (updated for AndroidX)

    Since the Support Library v24.2.0. you can achivie this very easy

    What you need to do is just:

    1. Add the design library to your dependecies

       dependencies {
           implementation "com.google.android.material:material:1.2.1"
       }
      

    2. Use TextInputEditText in conjunction with TextInputLayout

       <com.google.android.material.textfield.TextInputLayout
           xmlns:app="http://schemas.android.com/apk/res-auto"
           android:id="@+id/etPasswordLayout"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           app:passwordToggleEnabled="true">
      
           <android.support.design.widget.TextInputEditText
               android:id="@+id/etPassword"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:hint="@string/password_hint"
               android:inputType="textPassword"/>
       </com.google.android.material.textfield.TextInputLayout>
      

    passwordToggleEnabled attribute will make the password toggle appear

    1. In your root layout don't forget to add xmlns:app="http://schemas.android.com/apk/res-auto"

    2. You can customize your password toggle by using:

    app:passwordToggleDrawable - Drawable to use as the password input visibility toggle icon.
    app:passwordToggleTint - Icon to use for the password input visibility toggle.
    app:passwordToggleTintMode - Blending mode used to apply the background tint.

    More details in TextInputLayout documentation.

    這篇關(guān)于編輯文本密碼切換 Android的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Cut, copy, paste in android(在android中剪切、復(fù)制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數(shù)的數(shù)字)
Changing where cursor starts in an expanded EditText(更改光標(biāo)在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 日韩欧美三区 | 免费看a | 国产精品久久久久久吹潮 | a级片播放 | 97精品超碰一区二区三区 | 国产精品久久久久久久久大全 | 成人在线视频免费观看 | 日韩和的一区二区 | 精品欧美一区二区精品久久 | 亚洲综合在线网 | 国产真实乱全部视频 | 国产精品一区二区av | 久久99久久98精品免观看软件 | 国产激情综合五月久久 | 日韩精品一区二区三区 | 综合久久99 | 97伊人| 成人免费视频观看视频 | 天天操天天舔 | 亚洲欧美日韩电影 | 国产在线观看 | 国产精品自拍视频 | 麻豆久久 | 精品日韩一区二区 | 日本精品视频一区二区 | 国产日韩精品视频 | 国产区免费视频 | 91精品久久久久久久久 | 国产精品久久久久久久久久久新郎 | 精品久久香蕉国产线看观看亚洲 | 久久久久久久久久久久久久久久久久久久 | 特级a欧美做爰片毛片 | 99精品久久久 | 色视频欧美 | 亚洲一区二区三区免费在线观看 | 狠狠爱一区二区三区 | 亚洲国产视频一区二区 | 成人高清在线 | 一级黄色大片 | 久久久精| 免费的黄色片子 |