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

Android實(shí)現(xiàn)點(diǎn)擊獲取驗(yàn)證碼60秒后重新獲取功能

 更新時(shí)間:2018年06月05日 10:54:50   作者:Xia_焱  
這篇文章主要為大家詳細(xì)介紹了Android點(diǎn)擊獲取驗(yàn)證碼60秒后重新獲取驗(yàn)證碼的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)點(diǎn)擊獲取驗(yàn)證碼60秒后重新獲取的具體代碼,供大家參考,具體內(nèi)容如下

上代碼

/**
 * Created by Xia_焱 on 2017/5/7.
 */

public class CountDownTimerUtils extends CountDownTimer {
  private TextView mTextView;

  /**
   * @param millisInFuture  The number of millis in the future from the call
   *             to {@link #start()} until the countdown is done and {@link #onFinish()}
   *             is called.
   * @param countDownInterval The interval along the way to receive
   *             {@link #onTick(long)} callbacks.
   */
  public CountDownTimerUtils(TextView textView, long millisInFuture, long countDownInterval) {
    super(millisInFuture, countDownInterval);
    this.mTextView = textView;
  }

  @Override
  public void onTick(long millisUntilFinished) {
    mTextView.setClickable(false); //設(shè)置不可點(diǎn)擊
    mTextView.setText(millisUntilFinished / 1000 + "秒后可重新發(fā)送"); //設(shè)置倒計(jì)時(shí)時(shí)間
    mTextView.setBackgroundResource(R.drawable.bg_identify_code_press); //設(shè)置按鈕為灰
    SpannableString spannableString = new SpannableString(mTextView.getText().toString());
    ForegroundColorSpan span = new ForegroundColorSpan(Color.RED);
    spannableString.setSpan(span, 0, 2, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    mTextView.setText(spannableString);
  }

  @Override
  public void onFinish() {
    mTextView.setText("重新獲取驗(yàn)證碼");
    mTextView.setClickable(true);//重新獲得點(diǎn)擊
    mTextView.setBackgroundResource(R.drawable.bg_identify_code_normal);
  }
}

TextView背景色

bg_identify_code_press

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <solid android:color="#C0C0C0" /> <!--填充色 透明-->
  <corners android:radius="7dp" /> <!-- 圓角 -->
</shape>

bg_identify_code_normal

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <solid android:color="#2BAF2B" /> <!--填充色 透明-->
  <corners android:radius="7dp" /> <!-- 圓角 -->
</shape>

布局代碼

 <TextView
    android:id="@+id/tv_yzm"
    android:layout_width="match_parent"
    android:layout_marginTop="50dp"
    android:layout_height="45dp"
    android:background="@drawable/bg_identify_code_normal"
    android:gravity="center"
    android:text="點(diǎn)擊獲取驗(yàn)證碼"
    android:textColor="#FFF"
    android:textSize="15dp" />

項(xiàng)目代碼

 private void initView() {
    tv_yzm = (TextView) findViewById(R.id.tv_yzm);
    tv_yzm.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        CountDownTimerUtils mCountDownTimerUtils = new CountDownTimerUtils(tv_yzm, 60000, 1000);
        mCountDownTimerUtils.start();
      }
    });
  }

效果圖

這里寫圖片描述

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

相關(guān)文章

  • RecyclerView上拉加載封裝代碼

    RecyclerView上拉加載封裝代碼

    這篇文章主要為大家詳細(xì)介紹了RecyclerView上拉加載封裝代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • 淺談Android 中圖片的三級緩存策略

    淺談Android 中圖片的三級緩存策略

    本篇文章主要介紹了淺談Android 中圖片的三級緩存策略,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-10-10
  • Flutter 剪裁組件的使用

    Flutter 剪裁組件的使用

    今天我們主要聊聊 Flutter 中的幾個(gè)剪裁組件的使用,也是項(xiàng)目當(dāng)中經(jīng)??梢杂玫降?,希望你可以有所收獲
    2021-06-06
  • Android UI設(shè)計(jì)系列之自定義DrawView組件實(shí)現(xiàn)數(shù)字簽名效果(5)

    Android UI設(shè)計(jì)系列之自定義DrawView組件實(shí)現(xiàn)數(shù)字簽名效果(5)

    這篇文章主要介紹了Android UI設(shè)計(jì)系列之自定義DrawView組件實(shí)現(xiàn)數(shù)字簽名效果,具有一定的實(shí)用性和參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-06-06
  • 了解Android OpenGLES2.0(一)

    了解Android OpenGLES2.0(一)

    OpenGLES2.0是一個(gè)功能強(qiáng)大,調(diào)用方便的底層圖形庫,這篇文章主要為大家詳細(xì)介紹了Android OpenGLES2.0的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • Android平臺生成二維碼并實(shí)現(xiàn)掃描 & 識別功能

    Android平臺生成二維碼并實(shí)現(xiàn)掃描 & 識別功能

    這篇文章主要介紹了Android平臺生成二維碼并實(shí)現(xiàn)掃描 & 識別功能的相關(guān)資料,需要的朋友可以參考下
    2016-06-06
  • Android如何解析異構(gòu)列表

    Android如何解析異構(gòu)列表

    這篇文章主要介紹了Android如何解析異構(gòu)列表,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下
    2021-03-03
  • Android超實(shí)用的Toast提示框優(yōu)化分享

    Android超實(shí)用的Toast提示框優(yōu)化分享

    Toast是Android中用來顯示顯示信息的一種機(jī)制,和Dialog不一樣的是,Toast是沒有焦點(diǎn)的,而且Toast顯示的時(shí)間有限,過一定的時(shí)間就會(huì)自動(dòng)消失。那么這篇文章跟大家分享下Android中Toast的優(yōu)化,對大家日常開發(fā)還是很實(shí)用,下面來一起看看吧。
    2016-09-09
  • Android利用屬性動(dòng)畫實(shí)現(xiàn)優(yōu)酷菜單

    Android利用屬性動(dòng)畫實(shí)現(xiàn)優(yōu)酷菜單

    這篇文章主要為大家詳細(xì)介紹了Android利用屬性動(dòng)畫實(shí)現(xiàn)優(yōu)酷菜單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-01-01
  • Android仿360市場下載按鈕的實(shí)現(xiàn)方法

    Android仿360市場下載按鈕的實(shí)現(xiàn)方法

    這篇文章主要給大家介紹了關(guān)于利用Android實(shí)現(xiàn)360市場下載按鈕效果的方法,文中給出了詳細(xì)的示例代碼供大家參考學(xué)習(xí),并在文末給出了源碼供大家下載,需要的朋友們下面跟著小編一起來學(xué)習(xí)學(xué)習(xí)吧。
    2017-05-05

最新評論

塔河县| 榆林市| 澎湖县| 淮南市| 衡东县| 栾城县| 东明县| 车险| 龙陵县| 汝南县| 科尔| 邢台县| 板桥市| 天全县| 乌海市| 浦东新区| 德惠市| 安丘市| 舞钢市| 勐海县| 嘉义市| 隆子县| 宜君县| 阿瓦提县| 嘉义县| 双桥区| 孝感市| 衡阳市| 石渠县| 梧州市| 义马市| 句容市| 泰顺县| 北票市| 白朗县| 茌平县| 屏边| 泾阳县| 龙海市| 和顺县| 揭阳市|