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

Android仿微信或支付寶方塊密碼輸入框

 更新時間:2018年06月05日 11:12:57   作者:yaya_soft  
這篇文章主要為大家詳細(xì)介紹了Android仿微信或支付寶方塊密碼輸入框,具有一定的參考價值,感興趣的小伙伴們可以參考一下

在用到支付類或者驗(yàn)證類app時,都有一個簡密的輸入框。百度了下有個不錯的帖子,點(diǎn)擊打開鏈接

不過自己也寫了個簡單的類似的。

懶得運(yùn)行,直接截layout.xml的效果圖先。

布局文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  android:background="#ffffff" 
  android:paddingBottom="20dp" 
  android:paddingTop="30dp" > 
 
  <TextView 
    android:id="@+id/txtTitle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:text="請輸入驗(yàn)證碼" 
    android:textStyle="bold" 
    android:textSize="22sp" /> 
 
<LinearLayout 
  android:id="@+id/layout" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:layout_below="@+id/txtTitle" 
  android:layout_centerHorizontal="true" 
  android:layout_marginTop="10dp" 
  android:orientation="horizontal" > 
 
  <TextView 
    android:id="@+id/t1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/i1" 
    android:gravity="center" 
    android:inputType="number" 
    android:lines="1" 
    android:maxLines="1" /> 
 
  <TextView 
    android:id="@+id/t2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/i1" 
    android:gravity="center" 
    android:inputType="number" 
    android:lines="1" 
    android:maxLines="1" /> 
  <TextView 
    android:id="@+id/t3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/i1" 
    android:gravity="center" 
    android:inputType="number" 
    android:lines="1" 
    android:maxLines="1" /> 
 
  <TextView 
    android:id="@+id/t4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/i2" 
    android:gravity="center" 
    android:inputType="number" 
    android:lines="1" 
    android:maxLines="1" /> 
 
</LinearLayout> 
 
<EditText 
  android:id="@+id/editHide" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:layout_alignBottom="@+id/layout" 
  android:layout_alignLeft="@+id/layout" 
  android:layout_alignRight="@+id/layout" 
  android:layout_alignTop="@+id/layout" 
  android:layout_weight="1" 
  android:background="#00000000" 
  android:cursorVisible="false" 
  android:ems="10" 
  android:inputType="number" 
  android:maxLength="4" 
  android:textColor="#00000000" /> 
 
<LinearLayout 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:layout_below="@+id/layout" 
  android:layout_centerHorizontal="true" 
  android:layout_marginTop="20dp" > 
 
  <Button 
    android:id="@+id/verifycode_ok" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="#fa8d70" 
    android:layout_marginRight="30dp" 
    android:textColor="#ffffff" 
    android:text="確定" /> 
 
  <Button 
    android:id="@+id/verifycode_cancel" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="30dp" 
     android:background="@color/index_time_but" 
    android:textColor="#ffffff" 
    android:text="取消" /> 
 
</LinearLayout> 
 
</RelativeLayout> 

代碼:

import android.app.Activity; 
import android.os.Bundle; 
import android.text.Editable; 
import android.text.TextWatcher; 
import android.widget.EditText; 
import android.widget.TextView; 
 
public class MainActivity extends Activity { 
 
  TextView t1, t2, t3, t4, et; 
 
  String key = ""; 
 
  @Override 
  protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.verifycode); 
    t1 = (TextView) findViewById(R.id.t1); 
    t2 = (TextView) findViewById(R.id.t2); 
    t3 = (TextView) findViewById(R.id.t3); 
    t4 = (TextView) findViewById(R.id.t4); 
    et = (EditText) findViewById(R.id.editText1); 
    et.addTextChangedListener(tw); 
  } 
 
  void setKey() { 
    char[] arr = key.toCharArray(); 
    t1.setText(""); 
    t2.setText(""); 
    t3.setText(""); 
    t4.setText(""); 
    for (int i = 0; i < arr.length; i++) { 
      if (i == 0) { 
        t1.setText(String.valueOf(arr[0])); 
      } else if (i == 1) { 
        t2.setText(String.valueOf(arr[1])); 
      } else if (i == 2) { 
        t3.setText(String.valueOf(arr[2])); 
      } else if (i == 3) { 
        t4.setText(String.valueOf(arr[3])); 
      } 
    } 
  } 
 
  TextWatcher tw = new TextWatcher() { 
    @Override 
    public void onTextChanged(CharSequence s, int start, int before, 
        int count) { 
 
    } 
 
    @Override 
    public void beforeTextChanged(CharSequence s, int start, int count, 
        int after) { 
 
    } 
 
    @Override 
    public void afterTextChanged(Editable s) { 
      key = s.toString(); 
      setKey(); 
    } 
  }; 
} 

好噠,就這樣了,運(yùn)行就有效果了。沒有什么自定義,沒有什么第三方。

當(dāng)然。如果你要彈窗形式的話,也一樣,加下面的就能彈窗了

final AlertDialog dialog = new AlertDialog.Builder(mContext).create(); 
   dialog.show(); 
   dialog.getWindow().setContentView(R.layout.verifycode);t1 = (TextView) dialog.findViewById(R.id.t1); 
   t2 = (TextView) dialog.findViewById(R.id.t2); 
   t3 = (TextView) dialog.findViewById(R.id.t3); 
   t4 = (TextView) dialog.findViewById(R.id.t4); 

后期有時間再補(bǔ)上項(xiàng)目DOME。

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

相關(guān)文章

  • Android登錄界面的實(shí)現(xiàn)代碼分享

    Android登錄界面的實(shí)現(xiàn)代碼分享

    好久沒有搞android項(xiàng)目了,手都有點(diǎn)松了,今天因?yàn)轫?xiàng)目的需要,繼續(xù)弄android知識,在項(xiàng)目中登錄界面是項(xiàng)目中比較常見的最基本的功能,對android登錄界面的實(shí)現(xiàn)感興趣的朋友一起學(xué)習(xí)吧
    2016-11-11
  • Android評論圖片可移動順序選擇器(推薦)

    Android評論圖片可移動順序選擇器(推薦)

    這篇文章主要介紹了 Android評論圖片可移動順序選擇器的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-12-12
  • android自定義Toast設(shè)定顯示時間

    android自定義Toast設(shè)定顯示時間

    這篇文章主要為大家詳細(xì)介紹了android自定義Toast設(shè)定顯示時間,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • Android自定義view繪制圓環(huán)占比動畫

    Android自定義view繪制圓環(huán)占比動畫

    這篇文章主要為大家詳細(xì)介紹了Android自定義view繪制圓環(huán)占比動畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • Android5.0新特性詳解之全新的動畫

    Android5.0新特性詳解之全新的動畫

    這篇文章主要介紹了Android5.0新特性詳解之全新的動畫的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-09-09
  • Android?Studio調(diào)試Gradle插件詳情

    Android?Studio調(diào)試Gradle插件詳情

    這篇文章主要介紹了Android?Studio調(diào)試Gradle插件詳情,文章圍繞主題展開詳細(xì)的內(nèi)容戒殺,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-09-09
  • Android Kotlin Flow 冷熱流詳解

    Android Kotlin Flow 冷熱流詳解

    在Android開發(fā)中,Flow是Kotlin協(xié)程庫的重要組成部分,用于處理異步數(shù)據(jù)流,它能夠異步生產(chǎn)多個值,類似于RxJava中的Observable,本文介紹Android Kotlin Flow 冷熱流,感興趣的朋友一起看看吧
    2024-11-11
  • Android中注解處理器APT用法示例

    Android中注解處理器APT用法示例

    APT全稱Annotation Processing Tool,即注解處理器,APT是一種處理注釋的工具, 它對源代碼文件進(jìn)行檢測找出其中的注解,并使用注解進(jìn)行額外的處理,給我們自動生成代碼,簡化使用,很多流行框架都使用到了APT技術(shù),如 ButterKnife,Retrofit,Arouter,EventBus 等等
    2023-12-12
  • Android SDK中的Support兼容包詳解

    Android SDK中的Support兼容包詳解

    這篇文章主要介紹了Android SDK中的Support兼容包詳解,本文詳細(xì)區(qū)分了Support Library的版本區(qū)別、各種Theme的概念和使用注意事項(xiàng)等內(nèi)容,需要的朋友可以參考下
    2015-05-05
  • Android仿網(wǎng)易新聞圖片詳情下滑隱藏效果示例代碼

    Android仿網(wǎng)易新聞圖片詳情下滑隱藏效果示例代碼

    這篇文章主要給大家介紹了關(guān)于利用Android如何仿網(wǎng)易新聞圖片詳情下滑隱藏效果的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-07-07

最新評論

建昌县| 太白县| 天水市| 淳化县| 九龙坡区| 临沧市| 达孜县| 五莲县| 开江县| 平邑县| 什邡市| 新源县| 利川市| 玛纳斯县| 三亚市| 家居| 开化县| 章丘市| 石泉县| 浦东新区| 涟源市| 尼玛县| 来宾市| 涿鹿县| 大丰市| 常州市| 丽水市| 长丰县| 万荣县| 绍兴县| 临潭县| 宜兰县| 高雄市| 隆化县| 临高县| 龙口市| 新建县| 宣城市| 镇巴县| 宁南县| 西乌珠穆沁旗|