Android开发之SQLite(手机记账App)

MainActivity.class 源码片段

private static final String TAG = “SQLiteLOG”;
private MenuSelect menuSelect;
public int _id;
private Button but_save,but_update,but_delete;
private EditText name,money,remark;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

fab.setVisibility(0);

fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, “Replace with your own action”, Snackbar.LENGTH_LONG)
.setAction(“Action”, null).show();
}
});

name = (EditText)findViewById(R.id.item_name);
money = (EditText)findViewById(R.id.item_money);
remark = (EditText)findViewById(R.id.item_remark);

Bundle bundle = getIntent().getExtras();
if(bundle != null){
_id = Integer.valueOf(bundle.getString(“id”));
name.setText(bundle.getString(“name”));
money.setText(bundle.getString(“money”));
remark.setText(bundle.getString(“remark”));

}
init(this);

}

JQ方法实现页面定时执行的代码

 

<script src=”./jquery-1.8.2.min.js”></script>
<script>
var $handle;

function task_fuc(){
window.clearInterval($handle); //这里是清除句柄

//执行ajax请求
$.ajax({
url: “http://www.lanxinbase.com/task.php”,
complete:function(data)
{
//ajax返回以后继续设置定时任务.
$handle = window.setInterval(“task_fuc()”,10000);
}
});
}
$(document).ready(function(){
$handle = window.setInterval(“task_fuc()”,10000);//定时十秒执行一次task_fuc方法.
})

</script>

 

 

最近群里有人问,PHP怎么定时打开一个页面执行任务。所以这里就演示了一段代码,定时执行页面的方法。

 

 

 

 

 

 

android开发Timer使用方法

//先申明一个定时对象
Timer time = new Timer();


//增加一个计划任务(new TimerTask任务,开始启动时间,间隔执行时间)
time.schedule(new TimerTask() {
    @Override
    public void run() {
        Log.i(TAG,format.format(new Date()));

    }
},0,1000);

16566676869114
 
Copyright © 2008-2021 lanxinbase.com Rights Reserved. | 粤ICP备14086738号-3 |