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

Android仿京東首頁秒殺倒計(jì)時(shí)

 更新時(shí)間:2019年01月21日 16:58:32   作者:拉莫帥  
這篇文章主要為大家詳細(xì)介紹了Android仿京東首頁秒殺倒計(jì)時(shí),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android仿京東首頁秒殺倒計(jì)時(shí)的具體代碼,供大家參考,具體內(nèi)容如下

xml配置

<LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:background="#FFFFFF"
  android:orientation="vertical">
  <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="40dp"
  android:gravity="center_vertical">
  <TextView
   android:id="@+id/tv_miaosha"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_marginLeft="8dp"
   android:text="京東秒殺"
   android:textColor="#f00"
   android:textSize="20sp" />
  <TextView
   android:id="@+id/tv_miaosha_time"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:padding="5dp"
   android:text="12點(diǎn)場"
   android:textSize="20sp" />
  <LinearLayout
   android:layout_width="wrap_content"
   android:layout_height="wrap_content">
   <TextView
   android:id="@+id/tv_miaosha_shi"
   android:layout_width="25dp"
   android:layout_height="25dp"
   android:background="@drawable/shape_miaosha_time"
   android:gravity="center"
   android:text="1"
   android:textColor="#fff"
   android:textSize="15sp" />
   <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:padding="3dp"
   android:text=":" />
   <TextView
   android:id="@+id/tv_miaosha_minter"
   android:layout_width="25dp"
   android:layout_height="25dp"
   android:background="@drawable/shape_miaosha_time"
   android:gravity="center"
   android:text="1"
   android:textColor="#fff"
   android:textSize="15sp" />
   <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:padding="3dp"
   android:text=":" />
   <TextView
   android:id="@+id/tv_miaosha_second"
   android:layout_width="25dp"
   android:layout_height="25dp"
   android:background="@drawable/shape_miaosha_time"
   android:gravity="center"
   android:text="1"
   android:textColor="#fff"
   android:textSize="15sp" />
  </LinearLayout>
 </LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">
 <solid android:color="#000"></solid>
 <corners android:radius="2.5dp"></corners>
</shape>

方法內(nèi)容:

//得到控件
 mMiaoshaShiTv = view.findViewById(R.id.tv_miaosha_shi);
 mMiaoshaTimeTv = view.findViewById(R.id.tv_miaosha_time);
 mMiaoshaMinterTv = view.findViewById(R.id.tv_miaosha_minter);
 mMiaoshaSecondTv = view.findViewById(R.id.tv_miaosha_second);



 /****************京東秒殺倒計(jì)時(shí)**********************/

 //使用handler用于更新UI
 private Handler handler = new Handler() {
 @Override
 public void handleMessage(Message msg) {
  super.handleMessage(msg);
  countDown();
  handler.sendEmptyMessageDelayed(0, 1000);
 }
 };

 /**
 * 秒殺
 */
 private void countDown() {
 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 Date curDate = new Date(System.currentTimeMillis());
 String format = df.format(curDate);
 StringBuffer buffer = new StringBuffer();
 String substring = format.substring(0, 11);
 buffer.append(substring);
 Log.d("ccc", substring);
 Calendar calendar = Calendar.getInstance();
 int hour = calendar.get(Calendar.HOUR_OF_DAY);
 if (hour % 2 == 0) {
  mMiaoshaTimeTv.setText(hour + "點(diǎn)場");
  buffer.append((hour + 2));
  buffer.append(":00:00");
 } else {
  mMiaoshaTimeTv.setText((hour - 1) + "點(diǎn)場");
  buffer.append((hour + 1));
  buffer.append(":00:00");
 }
 String totime = buffer.toString();
 try {
  java.util.Date date = df.parse(totime);
  java.util.Date date1 = df.parse(format);
  long defferenttime = date.getTime() - date1.getTime();
  long days = defferenttime / (1000 * 60 * 60 * 24);
  long hours = (defferenttime - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
  long minute = (defferenttime - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60);
  long seconds = defferenttime % 60000;
  long second = Math.round((float) seconds / 1000);
  mMiaoshaShiTv.setText("0" + hours + "");
  if (minute >= 10) {
  mMiaoshaMinterTv.setText(minute + "");
  } else {
  mMiaoshaMinterTv.setText("0" + minute + "");
  }
  if (second >= 10) {
  mMiaoshaSecondTv.setText(second + "");
  } else {
  mMiaoshaSecondTv.setText("0" + second + "");
  }
 } catch (ParseException e) {
  e.printStackTrace();
 }
 }

 /***************京東秒殺倒計(jì)時(shí)****************/


開啟倒計(jì)時(shí):

handler.sendEmptyMessage(0);

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

相關(guān)文章

  • Android使用文件進(jìn)行IPC

    Android使用文件進(jìn)行IPC

    這篇文章主要為大家詳細(xì)介紹了Android使用文件進(jìn)行IPC,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • Android中SQLite 使用方法詳解

    Android中SQLite 使用方法詳解

    這篇文章主要介紹了Android中SQLite 使用方法詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • Linux系統(tǒng)下安裝android sdk的方法步驟

    Linux系統(tǒng)下安裝android sdk的方法步驟

    這篇文章主要介紹了Linux系統(tǒng)下安裝android sdk的方法步驟,文中介紹的非常詳細(xì),相信對大家具有一定的參考價(jià)值,需要的朋友可以們下面來一起看看吧。
    2017-03-03
  • Android AlertDialog六種創(chuàng)建方式案例詳解

    Android AlertDialog六種創(chuàng)建方式案例詳解

    這篇文章主要介紹了Android AlertDialog六種創(chuàng)建方式案例詳解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • Android編程之高效開發(fā)App的10個(gè)建議

    Android編程之高效開發(fā)App的10個(gè)建議

    這篇文章主要介紹了Android編程之高效開發(fā)App的10個(gè)建議,較為詳細(xì)的分析了Android開發(fā)中的常見問題與注意事項(xiàng),具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-10-10
  • Android 自定義驗(yàn)證碼輸入框的實(shí)例代碼(支持粘貼連續(xù)性)

    Android 自定義驗(yàn)證碼輸入框的實(shí)例代碼(支持粘貼連續(xù)性)

    這篇文章主要介紹了Android 自定義驗(yàn)證碼輸入框的實(shí)例代碼(支持粘貼連續(xù)性),代碼簡單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-10-10
  • 深入Android 五大布局對象的應(yīng)用

    深入Android 五大布局對象的應(yīng)用

    本篇文章小編為大家介紹,深入Android 五大布局對象的應(yīng)用。需要的朋友參考下
    2013-04-04
  • 輕松實(shí)現(xiàn)Android語音識別功能

    輕松實(shí)現(xiàn)Android語音識別功能

    這篇文章主要為初學(xué)者介紹了輕松實(shí)現(xiàn)Android語音識別功能的代碼,感興趣的小伙伴們可以參考一下
    2016-07-07
  • 一次OOM問題排查過程實(shí)戰(zhàn)記錄

    一次OOM問題排查過程實(shí)戰(zhàn)記錄

    這篇文章主要給大家介紹了一次OOM問題排查過程,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • Android實(shí)現(xiàn)自定義的彈幕效果

    Android實(shí)現(xiàn)自定義的彈幕效果

    現(xiàn)在的視頻網(wǎng)站基本都帶有彈幕效果,滿屏幕的文字從右到左飄來飄去??雌饋磉€蠻炫的,這篇文章就是來實(shí)現(xiàn)這個(gè)效果,大部分的都是從右向左移動(dòng)漂移,本文的效果中也支持從左向右的漂移移動(dòng)效果,同時(shí)也支持屏幕彈幕最多顯示個(gè)數(shù)的設(shè)置。有需要的可以參考借鑒。
    2016-08-08

最新評論

和田市| 二连浩特市| 滦南县| 同仁县| 宁安市| 称多县| 乌海市| 新源县| 甘南县| SHOW| 黄平县| 平潭县| 饶平县| 星子县| 富顺县| 锡林浩特市| 姜堰市| 靖宇县| 波密县| 光山县| 罗江县| 孝昌县| 大关县| 历史| 汽车| 马山县| 衡南县| 宜兴市| 虹口区| 上蔡县| 竹北市| 乌审旗| 故城县| 镇江市| 丹东市| 哈巴河县| 东山县| 拉孜县| 青海省| 漾濞| 竹溪县|