欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Android倒計(jì)時(shí)

感謝極客學(xué)院的視頻

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供邵陽(yáng)網(wǎng)站建設(shè)、邵陽(yáng)做網(wǎng)站、邵陽(yáng)網(wǎng)站設(shè)計(jì)、邵陽(yáng)網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、邵陽(yáng)企業(yè)網(wǎng)站模板建站服務(wù),十年邵陽(yáng)做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

布局文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.timer.MainActivity" >

    <EditText 
        android:id="@+id/inputtime"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        
        />
    
    <Button 
        android:id="@+id/settime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="set"
        />
    
    <TextView
        android:id="@+id/showtime"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />
    
    <LinearLayout 
        android:orientation="horizontal"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        >
        
        <Button
            android:id="@+id/starttime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="start"
            />
        
        <Button
            android:id="@+id/endtime"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="end"
            />
        
    </LinearLayout>

</LinearLayout>

下面是Java文件:

package com.example.timer;

import java.util.Timer;
import java.util.TimerTask;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity implements OnClickListener{
	
	EditText inputtime;
	Button settime,starttime,endtime;
	TextView showtime;
	private int i = 0 ;
	Timer timer = null;
	TimerTask task = null;
	
	private void init(){
		inputtime = (EditText)findViewById(R.id.inputtime);
		settime = (Button)findViewById(R.id.settime);
		starttime = (Button)findViewById(R.id.starttime);
		endtime = (Button)findViewById(R.id.endtime);
		showtime = (TextView)findViewById(R.id.showtime);
		settime.setOnClickListener(this);
		starttime.setOnClickListener(this);
		endtime.setOnClickListener(this);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		init();
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.settime:
			showtime.setText(inputtime.getText().toString());
			i = Integer.parseInt(inputtime.getText().toString());
			break;
		case R.id.starttime:
			startTime();
			break;
		case R.id.endtime:
			endTime();
			break;
		}
	}
	private Handler mHandler = new Handler(){
		public void handleMessage(Message msg){
			showtime.setText(msg.arg1+"");
			startTime();
		}
	};
	
	public void startTime(){
		timer = new Timer();
		task = new TimerTask(){

			@Override
			public void run() {
				// TODO Auto-generated method stub
				i--;
				Message message = mHandler.obtainMessage();
				message.arg1 = i;
				mHandler.sendMessage(message);
			}
			
		};
		timer.schedule(task,1000);//第二個(gè)參數(shù)表示以1000毫秒計(jì)時(shí)
	}

	public void endTime(){
		timer.cancel();
	}
}
  1. 設(shè)置監(jiān)聽(tīng)可以implements OnClickListener接口然后重寫onClick(View v)方法,然后給組件widget.setOnClickListener(this);然后在onClick()方法里抓取v.getId()

  2. TextView.setText(xxxx)里xxxx必須是字符串類型否則崩潰,可以用xxx.toString()也可以xxx+""自動(dòng)轉(zhuǎn)化

新聞標(biāo)題:Android倒計(jì)時(shí)
網(wǎng)站地址:http://aaarwkj.com/article46/gpideg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、網(wǎng)站營(yíng)銷、電子商務(wù)網(wǎng)站建設(shè)、小程序開(kāi)發(fā)、

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司
伊人激情久久综合中文字幕| 国产精品一区二区三区国产| 久久这里只有精品视频六| 日本精品免费专区在线观看| 四虎免费在线视频观看| 亚洲天堂av一区二区在线| 午夜丁香婷婷爽少妇av| 欧美日韩中文字幕精品视频| 日本大片在线一区二区三区| 天堂中文在线官网在线| 人人妻人人澡人人爽老妇| 久久最新视频中文字幕| 亚洲免费成人高清电影| 久久九九精品日本人妻视频| 国产真人作爱视频免费| 婷婷网色偷偷亚洲男人| 久久超碰一区二区三区| 亚洲欧美日韩之国产综合| 日韩一区二区高清视频在线观看| 日本束缚人妻一区二区三区| 国产高清亚洲一区亚洲二区| 刚出嫁新婚少妇很紧很爽| 2020中文字字幕在线不卡| 精品人妻一区二区三区观看| 免费国产网站在线观看不卡| 美女后入式在线观看| 大香蕉国产精品视频在线| 在线看黄色片播放器日韩| 欧美一区二区精品少妇| 天堂av新版在线观看| 欧美日韩一区二区高清在线| 传媒在线免费观看视频| 日韩精品一区福利合集| 中文字幕乱码亚洲美女精品| 91亚洲婷婷国产综合精品| 国产一级黄色片免费看| 欧美黄片在线免费观看| 91成人伦理在线观看| 蜜桃视频在线视频免费观看| 国产叼嘿一区二区视频| 99精品国产一区二区青青性色|