标签: handler

如何"模拟"Google地图标记上的点击?

我想做的是调用标记上的点击处理程序.所以这是我的代码:

var marker = new google.maps.Marker({
    position: location,
    map: map,
    title: title
});    

google.maps.event.addListener(marker, 'click', function() {
    alert("clicked");
});        

marker.click();
Run Code Online (Sandbox Code Playgroud)

但我看不到任何警告......

javascript click handler google-maps-api-3

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

asp.net中的ASHX处理程序文件有什么好处?

使用ashx或处理程序有什么好处?另外,如果我使用MVC(为什么不使用),我是否需要它们?

框架是否重要(2.0+)?

我为什么要使用处理程序?我最近建议使用一个来检索图像,但我不知道为什么.

感谢您的时间.

编辑 - 处理程序更快?

ashx handler

14
推荐指数
1
解决办法
2万
查看次数

Android:退出Looper?

我有一个线程,我用来定期更新我的Activity中的数据.我创建线程并启动一个looper以使用处理程序postDelay().在我的活动的onDestroy()中,我在我的处理程序上调用removeCallbacks().

我应该打电话handler.getLooper().quit()吗?或者不用担心它,让操作系统处理它?或者它会永远运行,消耗CPU周期?

multithreading android message-queue handler

14
推荐指数
2
解决办法
1万
查看次数

如何在Android中停止处理程序

在我的应用程序中,我使用Gridview创建了一个日历,在Gridview中,我在Imageview的帮助下显示日期和一些事件的可用性,为此,我创建了一个处理程序.

现在我想停止处理程序.

MainActivity.java

// inside oncreate

Handler handler = new Handler();
refreshCalendar();

// outside oncreate

public void refreshCalendar() { 
    calAdapter.refreshDays();
    calAdapter.notifyDataSetChanged();
    handler.post(calendarUpdater);
    calTitle.setText(android.text.format.DateFormat.format("MMMM yyyy", cal));
}
public Runnable calendarUpdater = new Runnable() {

    @Override
    public void run() {
        items.clear();
        allData = new ArrayList<HashMap<String,String>>();
        allData.clear();
        allData = db.showAllEvents();

        String currentDate = (String)android.text.format.DateFormat.format("MM/yyyy", cal);
        for(int i=0; i<allData.size(); i++)
        {
            String date[] = allData.get(i).get("date").split("/");
            String md[] = currentDate.split("/");
            if(date[1].equals(md[0]) && date[2].equals(md[1]))
            {
                items.add(date[0]);
                System.out.println("dates: "+date[0]);
            }
        }
        calAdapter.setItems(items);
        calAdapter.notifyDataSetChanged();
    }
};
Run Code Online (Sandbox Code Playgroud)

请告诉我应该如何以及在哪里禁用此线程.

android handler runnable

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

Python 日志记录 - AttributeError:模块“logging”没有属性“handlers”

观察:当我注释掉时,from logging import handlers会观察到以下错误。

Error:
    file_handler =  logging.handlers.RotatingFileHandler(
AttributeError: module 'logging' has no attribute 'handlers'
Run Code Online (Sandbox Code Playgroud)

问题:如果我已经导入,logging为什么需要这样做from logging import handlers

import logging
import sys
#from logging import handlers

def LoggerDefination():
    #file_handler = logging.FileHandler(filename='..\\logs\\BasicLogger_v0.1.log', mode='a')
    file_handler =  logging.handlers.RotatingFileHandler(
        filename="..\\logs\\BasicLogger_v0.2.log",
        mode='a',
        maxBytes=20000,
        backupCount=7,
        encoding=None,
        delay=0
    )
    file_handler.setLevel(logging.DEBUG)

    stdout_handler = logging.StreamHandler(sys.stdout)
    stdout_handler.setLevel(logging.DEBUG)
    handlers = [file_handler, stdout_handler]

    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s | %(module)s | %(name)s | LineNo_%(lineno)d | %(levelname)s |  %(message)s',
        handlers=handlers
    )

def fnt_test_log1():
    LoggerDefination()
    WriteLog1 = logging.getLogger('fnt_test_log1')
    #WriteLog1.propagate=False …
Run Code Online (Sandbox Code Playgroud)

python logging handler

14
推荐指数
2
解决办法
4万
查看次数

处理程序或听众.什么是更好的?

处理程序或听众.事件通知有什么用?什么是更快,更有效等?

android listener handler

13
推荐指数
2
解决办法
3791
查看次数

Python日志记录:为什么__init__被调用两次?

我试图使用配置文件和自己的处理程序python日志记录.这在某种程度上起作用.让我感到困惑的是__init__两次__del__被召唤并被召唤一次.当我删除整个配置文件的东西并直接在代码中创建处理程序__init__被调用一次并且__del__永远不会被调用.

我的问题:

  1. 为什么__init__叫两次?
  2. 为什么被__del__召唤的频率低于__init__

代码:

#!/bin/env python

import logging
import logging.handlers
import logging.config

class Test1TimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
    def __init__(self,filename):
        print "init called"
        logging.handlers.TimedRotatingFileHandler.__init__(self,filename, when='S', interval=86400, backupCount=8, encoding=None)

    def __del__(self):
        print "del called"
        if hasattr(logging.handlers.TimedRotatingFileHandler,"__del__"):
            logging.handlers.TimedRotatingFileHandler.__del__(self)

logging.config.fileConfig('/root/test1.conf')
logger = logging.getLogger("test1")
Run Code Online (Sandbox Code Playgroud)

配置文件:

[formatters]
keys: simple

[handlers]
keys: file

[loggers]
keys: root

[formatter_simple]
format: "%(message)s"

[handler_file]
class: test1.Test1TimedRotatingFileHandler
args: ("/root/test1.log",)
level=INFO

[logger_root]
level: INFO
handlers: file
qualname: test1
Run Code Online (Sandbox Code Playgroud)

输出如下:

init called …
Run Code Online (Sandbox Code Playgroud)

python logging config init handler

13
推荐指数
2
解决办法
5080
查看次数

使用协议处理程序(即:url)从Chrome打开Internet Explorer

我已按照以下步骤操作,但对我来说无法正常工作。 Chrome中的自定义协议处理程序

基本上,我没有自定义应用。我只想创建一个处理程序以使用特定的URL打开IE。

这是我的规定:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\ie]
"URL Protocol"="\"\""
@="\"URL:IE Protocol\""

[HKEY_CURRENT_USER\Software\Classes\ie\DefaultIcon]
@="\"explorer.exe,1\""

[HKEY_CURRENT_USER\Software\Classes\ie\shell]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open\command]
@="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" \"%1\""
Run Code Online (Sandbox Code Playgroud)

它正在工作,但是...当我从Chrome打开ie:www.google.com时,它要求打开IE,但它在打开的URL中保留了“ ie:” ...这会产生无限循环。

我该如何解决?

谢谢

屏幕截图

windows internet-explorer handler protocol-handler

13
推荐指数
2
解决办法
8059
查看次数

应用程序崩溃与"从错误的线程异常调用"

我在我的onCreate()方法中添加了这部分代码,它崩溃了我的应用程序.需要帮忙.

logcat的:

android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread 
that created a view hierarchy can touch its views.
Run Code Online (Sandbox Code Playgroud)

码:

final TextView timerDisplayPanel = (TextView) findViewById(R.id.textView2);

    Timer t = new Timer();
    t.schedule(new TimerTask(){
        public void run(){
            timerInt++;
            Log.d("timer", "timer");
            timerDisplayPanel.setText("Time ="+ timerInt +"Sec");
        }
    },10, 1000);
Run Code Online (Sandbox Code Playgroud)

android handler timertask

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

postDelayed()在kotlin中使用了什么

据我所知postDelayed()有两个参数runnable和duration delay.在kotlin下面的代码实际上做了什么:

Handler().postDelayed({
            sendMessage(MSG, params.id)
            taskFinished(params, false)
        }, duration)
Run Code Online (Sandbox Code Playgroud)

这里第一个是两个函数调用,第二个是持续时间延迟.哪里可以运行?这对于kotlin来说是不是像lambda?有人请解释一下吗?

android handler kotlin

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