導航:首頁 > 操作系統 > android開發時鍾

android開發時鍾

發布時間:2022-06-05 22:02:11

android開發桌面時鍾,怎麼根據系統時間的變化更新Widget

alarm=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC, time.toMillis(true), 1000, refreshIntent);
1s更新1次,看看

② android 模擬時鍾 手指觸動旋轉指針

平面座標上有兩點,計算角度這個是初中生的問題啊 dY/dX 就是斜率,有斜率就有角度

③ android 鬧鍾設置的幾種方法

鬧鍾創建方法:功能表-時鍾-鬧鍾-創建鬧鍾
關機鬧鍾:功能表-時鍾-鬧鍾-菜單-鬧鍾前開機-鬧鍾前開機打鉤。
若您需添加多個鬧鍾,建議您操作應用程序—時鍾—鬧鍾—點「+」號創建鬧鍾,設置好後點擊存儲。再點「+」即可再創建一個鬧鍾。

④ 如何用android設計一個程序包括鬧鍾,時鍾,秒錶,計時

Android的程序界面,找到名為圖標:時鍾,點擊進入四個項目,鬧鍾,世界時鍾,秒錶,倒計時。您可以選擇報警的那一個,看看裡面是否有可以刪除的鬧鍾。

⑤ 在android開發中,我設計了一個帶秒針的時鍾,它是一個widget插件。如何讓它只有顯示出來時才刷新界面

你是不是在用service定時進行時間刷新?
可以試試屏幕變暗,還有鎖屏等事件中讓刷新線程暫停,恢復後繼續

⑥ Android上有什麼好的時鍾插件

ExtDateWidgetPro 我也用這個插件,可以換顏色,很好用~

⑦ 安卓開發有一個模擬時鍾,怎麼在MainActivity里改變時鍾的初始時間

http://www.eoeandroid.com/thread-108663-1-1.html這里可能對你有幫忙

⑧ Android上開發一個長達幾天的倒計時小軟體, 把它做成service 還是做成能夠保留在後台的Activity

很久以前寫過這么個:
//TimerLabel.java
package timerlabel;

import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.lang.Thread.State;

/**
* 計時標簽
* @author Jeky
*/
public class TimerLabel extends JLabel {

private int maxTime;
private int count;
private static final int SECOND = 1000;
private static final int FONT_SIZE = 36;
private Thread thread;
private boolean pause;
private boolean start;

/**
* 新建一個計時標簽
* @param maxTime 倒計時起始時間
*/
public TimerLabel(int maxTime) {
this.setHorizontalAlignment(JLabel.CENTER);
this.setFont(new Font("Times New Roman", Font.BOLD, FONT_SIZE));
this.pause = false;
setMaxTime(maxTime);
}

/**
* 修改倒計時起始時間
* @param maxTime 新的起始時間
*/
public void setMaxTime(int maxTime) {
if (this.start) {
return;
}
this.maxTime = maxTime;
this.count = maxTime;
initText();
this.thread = new Thread(new Runnable() {

@Override
public void run() {
while (count != 0) {
try {
if (!start) {
count = 0;
initText();
break;
}
if (!pause) {
Thread.sleep(SECOND);
count--;
initText();
}
} catch (InterruptedException ex) {
pause = true;
}
}
done();
}
});
this.start = false;
}

/**
* 倒計時完成後調用此方法
*/
protected void done() {
JOptionPane.showMessageDialog(this, "Time up!");
}

/**
* 標簽字元由此方法設置
*/
protected void initText() {
String min = String.valueOf(count / 60);
String sec = String.valueOf(count % 60);
while (min.length() < 2) {
min = "0" + min;
}
while (sec.length() < 2) {
sec = "0" + sec;
}
this.setText(min + ":" + sec);
}

/**
* 暫停
*/
public void pause() {
if (start) {
thread.interrupt();
}
}

/**
* 檢測標簽倒計時是否開始
* @return 如果開始返回true
*/
public boolean isStart() {
return start;
}

/**
* 得到倒計時起始時間
* @return 倒計時起始時間
*/
public int getMaxTime() {
return maxTime;
}

/**
* 檢測標簽倒計時是否暫停
* @return 倒計時暫停返回true
*/
public boolean isPause() {
return pause;
}

/**
* 從暫停中恢復計時
*/
public void continueDo() {
if (this.pause) {
this.pause = false;
}
}

/**
* 取消計時
*/
public void stop() {
if (start) {
start = false;
}
}

/**
* 開始計時
*/
public void start() {
if (thread.getState().equals(State.NEW)) {
start = true;
thread.start();
} else if (thread.getState().equals(State.TERMINATED)) {
setMaxTime(maxTime);
start = true;
thread.start();
}
}
}

//演示程序 Test.java
package timerlabel;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
* @author Jeky
*/
public class Test extends JFrame {

private TimerLabel label;
private static final int GAP = 10;
private JButton runButton;
private JButton pauseButton;
private JButton setButton;
private JButton stopButton;
private JTextField time;

public Test() {
label = new TimerLabel(10);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, GAP, GAP));

runButton = new JButton("Start");
runButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
label.start();
}
});
panel.add(runButton);

pauseButton = new JButton("Pause");
pauseButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
if (label.isStart()) {
if (!label.isPause()) {
label.pause();
pauseButton.setText("Continue");
} else {
label.continueDo();
pauseButton.setText("Pause");
}
}
}
});
panel.add(pauseButton);

time = new JTextField(10);
panel.add(time);

setButton = new JButton("setMaxTime");
setButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
label.setMaxTime(Integer.parseInt(time.getText()));
}
});
panel.add(setButton);

stopButton = new JButton("Stop");
stopButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
label.stop();
}
});
panel.add(stopButton);

this.getContentPane().add(label, BorderLayout.CENTER);
this.getContentPane().add(panel, BorderLayout.SOUTH);

this.setVisible(true);
this.setSize(500, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main(String[] args) {
new Test();
}
}

試試吧

⑨ android 怎麼實現計時器時分秒的操作

可以Calendar.getInstance().get(Calendar.HOUR),獲取當前時間,然後計算時間差

閱讀全文

與android開發時鍾相關的資料

熱點內容
百度店鋪客戶訂單手機加密 瀏覽:498
釘釘班群文件夾怎麼上傳文件 瀏覽:747
人社app怎麼解綁手機 瀏覽:99
caj文件夾打不開 瀏覽:473
什麼app可以將電量變色 瀏覽:692
解放出你的解壓抖音小游戲 瀏覽:345
什麼方式解壓比較好 瀏覽:266
erp是什麼伺服器 瀏覽:185
python中tmp 瀏覽:21
說明wpf加密過程 瀏覽:143
java讀取list 瀏覽:703
iis7gzip壓縮 瀏覽:39
有什麼安卓機打吃雞好 瀏覽:598
三星u盤加密狗 瀏覽:474
php函數的返回值嗎 瀏覽:587
國企穩定程序員 瀏覽:328
編程貓如何使用教程視頻 瀏覽:218
安卓遠端網頁如何打日誌 瀏覽:218
壓縮flash大小 瀏覽:993
解壓的玩具教程可愛版 瀏覽:366