我在Android中创建了一个样本/演示/测试程序,运行得非常好,如果你看到下面你会看到我创建了一个线程.现在我想创建另一个线程来处理另一个处理程序...因为我不能有两个run()方法...我该怎么做?
这是我的(工作 - 没有错误)计划:
package com.ryan1;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;
public class main extends Activity implements Runnable{
int level = 0;
int seconds_running=0;
TextView the_seconds,the_level;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
the_seconds = (TextView) findViewById(R.id.textview_seconds);
the_level = (TextView) findViewById(R.id.textview_level);
Thread thread = new Thread(this);
Thread thread2 = new Thread(this);
thread.start();
thread2.start();
}
public void run() {
while(seconds_running<500)
{
if(seconds_running %5 ==0){level++;}
try {
handler.sendEmptyMessage(0);
int a = 1000 - (level*100); …Run Code Online (Sandbox Code Playgroud) 嘿!
我的机器和生产服务器上有一个本地测试服务器.
我想要包含一个如下所示的db.php文件,而不是不断编辑我的数据库凭据:
<?php
var $hostt = "localhost";
var $db_database = "testdb";
var $db_username = "root";
var $db_password= "";
?>
Run Code Online (Sandbox Code Playgroud)
但当我尝试这样包括它:
<?php
class testme{
include_once "db.php";
...
Run Code Online (Sandbox Code Playgroud)
它拒绝工作并吐出: 解析错误:语法错误,意外T_INCLUDE_ONCE,期待T_FUNCTION in
我怎样才能让它以我想要的方式工作?是可能还是我吠叫错了树?
谢谢![R
当我开始我的脚本时,我有这个:
var my_great_masterpiece = new function ()
{
var self = this;
Run Code Online (Sandbox Code Playgroud)
然后在我的脚本中我有这个:
response_xml: function ()
{
if (self.http_request.readyState == 4)
{
if (self.http_request.status == 404 && countXmlUrl <= 3)
{
countXmlUrl++;
self.realXmlUrl = xmlUrl[countXmlUrl];
self.request_xml();
}
if (self.http_request.status == 200)
{
self.xmlDoc = self.http_request.responseXML;
self.storage.setItem('domains_raw_xml', self.http_request.responseText);
self.main.peter_save_data();
self.timervar = setTimeout(function ()
{
// ########### Below line gives the error #############################
self.new_version_show_window();
}, 2000);
}
}
},
new_version_show_window: function ()
{
...
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
错误:self.new_version_show_window不是函数
我究竟做错了什么?
谢谢!
我有一个Firefox插件,它首先显示一个警告/信息页面,告诉用户他们被重定向(chrome://localfilter/content/wait_page.html),然后将它们重定向到目的地.
一切都很好.
唯一的事情就是当他们按下后退按钮他们看到"等待页面"时,无论如何从历史记录中删除该等待页面并保留其他所有内容?或者,如果这是不可能的,用另一个可能只有徽标的页面替换那个等待页面(因为如果他们读了它们就会被重定向,没有任何反应......)
编辑:
// function to see if the banned URL is on the list, then redirect
...
window.stop(); // Totally stop the page from loading.
window.content.location.href = "chrome://quickfilter/content/wait_page.html";
this.notificationBox();
self.timervar = setTimeout(function ()
{
self.main.redirectToAnotherUrl();
}, 2505);
...
redirectToAnotherUrl: function ()
{
window.content.location.href = self.mafiaafireFilterUrl;
self.timervar = setTimeout(function ()
{
self.main.notificationBox();
}, 2005);
}
Run Code Online (Sandbox Code Playgroud)
更换时更改:
redirectToAnotherUrl: function ()
{
window.content.location.replace(self.mafiaafireFilterUrl);
self.timervar = setTimeout(function ()
{
self.main.notificationBox();
}, 2005);
}
Run Code Online (Sandbox Code Playgroud) 在我的数据库中,我有一个名为的字段:expires_in并且具有诸如2015-05-01(YYYY-MM-DD)之类的值,我需要在此字段(从PHP)上搜索并返回
a)低于今天的日期(例如昨天或x天前)
b)日期大于今天但距离今天不到2周
我有一种感觉,如果我知道a那么b不会很难......