标签: countdowntimer

显示python睡眠功能的倒计时

我在我的程序中使用time.sleep(10).我运行程序时可以在shell中显示倒计时吗?

>>>run_my_program()
tasks done, now sleeping for 10 seconds
Run Code Online (Sandbox Code Playgroud)

然后我想要它做10,9,8,7 ....

这可能吗?

python time sleep stopwatch countdowntimer

13
推荐指数
4
解决办法
3万
查看次数

Angular 2 - 倒数计时器

我愿意在Angular 2中做一个从60开始的倒数计时器(即59,58,57等......)

为此,我有以下内容:

constructor(){
  Observable.timer(0,1000).subscribe(timer=>{
  this.counter = timer;
});
}
Run Code Online (Sandbox Code Playgroud)

以上,每秒滴答,这很好; 但是,它按升序排列为无限数量.我不确定是否有办法调整它,所以我可以有一个倒数计时器.

countdown rxjs countdowntimer angular

13
推荐指数
1
解决办法
3万
查看次数

滚动时,RecyclerView中的多个倒计时器会闪烁

我已经为每个RecyclerView项目实现了倒计时器,这是一个片段活动.倒计时器显示到期时间.倒计时器工作正常,但向上滚动时会开始闪烁.搜索了很多,但没有得到很好的参考.谁能帮我?

这是我的RecyclerView适配器

public class MyOfferAdapter extends RecyclerView.Adapter<MyOfferAdapter.FeedViewHolder>{
private final Context mContext;
private final LayoutInflater mLayoutInflater;
private ArrayList<Transactions> mItems = new ArrayList<>();
private ImageLoader mImageLoader;
private String imageURL;
private View mView;
private String mUserEmail;

public MyOfferAdapter(Context context) {
    mContext = context;
    mLayoutInflater = LayoutInflater.from(context);
    VolleySingleton mVolley = VolleySingleton.getInstance(mContext);
    mImageLoader = mVolley.getImageLoader();
}


public void addItems(ArrayList<Transactions> items,String userEmail) {
    int count = mItems.size();
    mItems.addAll(items);
    mUserEmail = userEmail;
    notifyItemRangeChanged(count, items.size());
}


@Override
public FeedViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    mView = mLayoutInflater.inflate(R.layout.my_feed_item_layout, parent, …
Run Code Online (Sandbox Code Playgroud)

android countdowntimer android-recyclerview

12
推荐指数
2
解决办法
7460
查看次数

如何在android中停止CountDownTimer

怎么停止这个计时器,任何想法?

我想在每个查询中重置计时器,但它会继续.每个新查询都会添加新的计时器.怎么解决这个?

 new CountDownTimer(zaman, 1000) {                     //geriye sayma

            public void onTick(long millisUntilFinished) {

                NumberFormat f = new DecimalFormat("00");
                long hour = (millisUntilFinished / 3600000) % 24;
                long min = (millisUntilFinished / 60000) % 60;
                long sec = (millisUntilFinished / 1000) % 60;

                cMeter.setText(f.format(hour) + ":" + f.format(min) + ":" + f.format(sec));
            }

            public void onFinish() {
                cMeter.setText("00:00:00");
            }
        }.start();
Run Code Online (Sandbox Code Playgroud)

android countdowntimer android-studio

12
推荐指数
2
解决办法
3万
查看次数

Kotlin –简单的倒数计时器

我知道如何在Java中创建一个简单的20秒倒数计时器。但是我想在Kotlin中创建这个。

package android.os;

new CountDownTimer(20000, 1000) {
    public void onTick(long millisUntilFinished) {
        mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
    }
    public void onFinish() {
        mTextField.setText("Time's finished!");
    }
}.start();
Run Code Online (Sandbox Code Playgroud)

如何使用Kotlin做到这一点?

android countdowntimer kotlin

12
推荐指数
9
解决办法
1万
查看次数

Javasacript倒数计时器,以天,小时,分钟,秒为单位

我正在尝试创建一个基于时间的倒计时时钟.它不是基于current_dates.将被拉出的初始时间将来自一个单独的php文件.这将是基于浏览器的游戏.当有人单击按钮以启动此脚本时.它将检查是否满足某些要求,如果是,那么此脚本将启动.根据对象的级别,它将拉出该进程级别的初始计时器.希望有道理.无论如何我将计时器脚本从我提供的第一个代码中删除.

此脚本仅占用分钟和秒.我将其修改为包括日期和小时.在这个过程的某个地方,我搞砸了,脚本根本不起作用.我也不太确定这是否是计算这个的最佳方法.所以,如果你有一个更干净的方法,请分享.先感谢您.

这个脚本基于我看到的分钟/秒脚本.这是原始来源:

<span id="countdown" class="timer"></span>
<script>
   var seconds = 60;
   function secondPassed() {
   var minutes = Math.round((seconds - 30)/60);
   var remainingSeconds = seconds % 60;
   if (remainingSeconds < 10) {
      remainingSeconds = "0" + remainingSeconds; 
   }
   document.getElementById('countdown').innerHTML = minutes + ":" + remainingSeconds;
   if (seconds == 0) {
    clearInterval(countdownTimer);
    document.getElementById('countdown').innerHTML = "Buzz Buzz";
   } else {
    seconds--;
   }
   }
   var countdownTimer = setInterval('secondPassed()', 1000);
</script>
Run Code Online (Sandbox Code Playgroud)

这是我尝试包含天,小时,分钟和秒的修改过的脚本.

<span id="countdown"></span>
<script>
     var current_level = 93578;

     function timer() {

        var days = …
Run Code Online (Sandbox Code Playgroud)

javascript php timer countdowntimer

10
推荐指数
1
解决办法
4万
查看次数

如何在通知视图中制作倒计时器?

我想出了如何使用RemoteViews类创建自定义视图.我也知道如何使用ChronometerProgressBar内部RemoteViews.

但是如何进行倒计时View,几乎完全相同,Chronometer但不同之处在于它会倒计时而不是向上计数?

我试图复制Chronometer类的来源并修改它以便它符合我的需要,但有一些注释@android.view.RemotableViewMethod,我无法导入到我的项目中.不幸的是,如果没有注释,它就无法工作,因为RemoteViews它们使用它们来传递值.

我的第二个想法是扩展Chronometer类并覆盖正确的方法,但它们是private.

任何想法,都有可能吗?(还有一个问题,因为我不确定:如果方法是注释的并且我重写了这个方法,那么注释是继承的吗?)

android android-notifications countdowntimer

9
推荐指数
1
解决办法
2806
查看次数

ListView和具有倒数计时器的项目

我的Listview有问题,我想为所有ListView的项目设置一个倒数计时器,我已经用Google搜索了一个解决方案,但它无法正常工作.问题是ListView重用(回收)一个视图,我总是得到一个错误的项目时间.我使用标签作为我的观点,但它仍然不起作用,我无法理解我在哪里犯了错误,请帮助我.谢谢.

所以这里有一张图片显示我的问题:pic1我刚刚开始一个活动; startActivity

pic2我只是向下滚动

listWithError

在这里我的代码(全班):

更新

    public class PromoListActivity extends SherlockActivity {
private ListView mPromoList;
private PromoListAdapter mAdapter;
private ViewFlipper mFlipper;
private Button mBtnRepeat;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_news_list);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setTitle("??????????? ?????");
    mFlipper = (ViewFlipper) findViewById(R.id.flipper);
    mPromoList = (ListView) findViewById(R.id.newsList);
    mBtnRepeat = (Button) findViewById(R.id.btnRepeat);

    //-->
    final Handler timerHandler = new Handler();
    Runnable timerRunnable = new Runnable() {
        @Override
        public void run() {
            mAdapter.notifyDataSetChanged();
            timerHandler.postDelayed(this, 1000); // run every minute
        }
    };
    //<--


    mBtnRepeat.setOnClickListener(new OnClickListener() {

        @Override
        public void …
Run Code Online (Sandbox Code Playgroud)

android listview multiplying countdowntimer

9
推荐指数
1
解决办法
8881
查看次数

是否可以在Android上的操作栏中添加计时器?

我想要一个简单的mm:ss计时器显示在我的操作栏上,能够选择开始倒计时的分钟数,然后一旦它在0时调用一个方法.这可能吗?如何?谢谢

countdowntimer android-actionbar

8
推荐指数
1
解决办法
3484
查看次数

带有多个倒计时器的Recyclerview会导致闪烁

我想表明我的每个单元格内剩下多少时间RecyclerView......因为我已经为每个单元格使用了倒数计时器.在每一行我开始一个计数器并管理onTick()...所有工作都按预期工作...我有一个计时器勾选每一行,我的单元格也在更新但我的单元格现在闪烁....当它变得疯狂时我滚动.

这是我的适配器......

if (product.getProductType().equalsIgnoreCase("Auction Product")) {
                isAuction=true;
                viewHolder.img_product_type.setImageResource(R.drawable.bid);
                viewHolder.txt_timeleft.setVisibility(View.VISIBLE);
               start_countDown(product.getStart(),product.getStop(),viewHolder.txt_timeleft);
            }
Run Code Online (Sandbox Code Playgroud)

计数器代码如下....

private void start_countDown(String start, String stop, final TextView txt_timeleft) {
        try {
            //Log.e("hetal",start+"....."+stop);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            Calendar start_date = Calendar.getInstance();
            start_date.setTime(format.parse(start));

            Calendar end_date = Calendar.getInstance();
            end_date.setTime(format.parse(stop));

            final Calendar today = Calendar.getInstance();
            CountDownTimer timer;

            txt_timeleft.setTextColor(Color.DKGRAY);
            if(today.before(start_date)){
                txt_timeleft.setTextColor(context.getResources().getColor(R.color.red));
                txt_timeleft.setText(context.getString(R.string.auction_not_start));
                Animation anim = new AlphaAnimation(0.0f, 1.0f);
                anim.setDuration(1000); //You can manage the time of the blink with this parameter
                anim.setStartOffset(20);
                anim.setRepeatMode(Animation.REVERSE);
                anim.setRepeatCount(Animation.INFINITE);
                txt_timeleft.startAnimation(anim);
                return;
            } …
Run Code Online (Sandbox Code Playgroud)

android countdowntimer android-recyclerview

8
推荐指数
1
解决办法
7083
查看次数