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

如何使用自定義圖像編輯文本密碼,如軸銀行應

How to use custom image for edittext password like axis bank app(如何使用自定義圖像編輯文本密碼,如軸銀行應用程序)
本文介紹了如何使用自定義圖像編輯文本密碼,如軸銀行應用程序的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何在edittext密碼字段中使用自定義圖像而不是'*'?

看圖:

任何答案或提示將不勝感激.

解決方案

答案來自.

公共類 MyPasswordTransformationMethod 擴展 PasswordTransformationMethod {@覆蓋public CharSequence getTransformation(CharSequence source, View view) {return new PasswordCharSequence(source);}私有類 PasswordCharSequence 實現 CharSequence {私人 CharSequence mSource;公共密碼字符序列(字符序列源){mSource = 來源;//存儲字符序列}公共 char charAt(int index) {返回 '??';//這是重要的部分}公共整數長度(){返回 mSource.length();//返回默認值}公共 CharSequence subSequence(int start, int end) {返回 mSource.subSequence(開始,結束);//返回默認值}}};

參考:在android中如何在輸入類型為textPassword的EditText中顯示星號(*)代替點?

How to use custom image instead of '*' in edittext password field?

see image:

Any answer or hint will be greatly appreciated.

解決方案

The answer comes from this tutorial and it covers a behaviour when a user:

  • enters into the login screen, keyboard will open automatically.

  • tries to enter value in it then textbox background changes to textbox with star background.

  • tries to cancel/delete the input value by using back key on keyboard then textbox background will change to textbox without star background.

First of all you have to create two drawables:

Then, according to this approach, you have to implement addTextChangedListener method on your EditText. After that, as a parameter, you create a new instance of a TextWatcher class and you implement its methods:

etxtPin1.addTextChangedListener(new TextWatcher() {

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
       // TODO Auto-generated method stub

    }
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
                // TODO Auto-generated method stub

    }
    @Override
    public void afterTextChanged(Editable s) {
          if(etxtPin1.getText().toString().trim().length()==1){

          etxtPin1.clearFocus();
          etxtPin2.requestFocus();
          etxtPin1.setBackgroundResource(R.drawable.pin_txt_bg_star);

          }
       }
    });

Then, you have to implement setOnKeyListener and its method onKey:

this.etxtPin1.setOnKeyListener(new View.OnKeyListener() {
      public boolean onKey(View paramView, int paramInt, KeyEvent paramKeyEvent) {
           if ((paramKeyEvent.getAction() == KeyEvent.ACTION_DOWN)&&(paramInt == 67) && (LoginActivity.this.etxtPin2.getText().length() == 0)) {
               etxtPin1.requestFocus();
               etxtPin1.setBackgroundResource(R.drawable.pin_txt_bg);
               etxtPin1.setText("");
           }

           return false;
       }
    });


Another approach: create you own class which extends PasswordTransformationMethod.

public class MyPasswordTransformationMethod extends PasswordTransformationMethod {
    @Override
    public CharSequence getTransformation(CharSequence source, View view) {
        return new PasswordCharSequence(source);
    }

    private class PasswordCharSequence implements CharSequence {
        private CharSequence mSource;
        public PasswordCharSequence(CharSequence source) {
            mSource = source; // Store char sequence
        }
        public char charAt(int index) {
            return '*'; // This is the important part
        }
        public int length() {
            return mSource.length(); // Return default
        }
        public CharSequence subSequence(int start, int end) {
            return mSource.subSequence(start, end); // Return default
        }
    }
};

Reference: In android how to show asterisk (*) in place of dots in EditText having inputtype as textPassword?

這篇關于如何使用自定義圖像編輯文本密碼,如軸銀行應用程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 亚洲精品国产第一综合99久久 | 欧美精品一区二区三区蜜桃视频 | 国产精品久久久久久妇女6080 | 看特级黄色片 | 欧美精品一区二区三区蜜桃视频 | 91综合在线观看 | 亚洲精选一区 | 黄色免费在线网址 | 久久亚洲一区二区三区四区 | 久久综合影院 | 亚洲精品一区在线 | 福利一区在线观看 | 成人欧美一区二区三区在线播放 | 日韩成人在线视频 | 亚洲一区二区免费视频 | 免费久久视频 | 九色 在线| 亚洲二区在线观看 | 久久久亚洲一区 | 91大神在线看 | 亚洲日本欧美日韩高观看 | 在线日韩欧美 | 亚洲风情在线观看 | 国产精品九九九 | 久草资源 | 久久精品国产清自在天天线 | 欧美一区二区三区 | 日日夜夜免费精品 | 国产成人精品一区二区三区视频 | 91av在线视频观看 | 天天射影院 | 91免费版在线 | 瑞克和莫蒂第五季在线观看 | 久久精品国产a三级三级三级 | 日韩久久久一区二区 | 二区精品 | av中文字幕在线 | 成人国产免费视频 | 成人一区二区三区在线观看 | 三级免费 | 中文字幕电影在线观看 |