使用Spring在xml上下文中,我们可以像这样简单地加载属性:
<context:property-placeholder location:"classpath*:app.properties"/>
Run Code Online (Sandbox Code Playgroud)
有没有机会在没有样板的情况下在@Configuration bean(~java代码)中配置相同的属性?
谢谢!
我正在为密码字段实现自定义键盘(通过自定义视图)并尝试添加辅助功能,因此当用户单击视图时,它应该发出选定的值.
在我的自定义键盘中,我需要坐标,MotionEvent因此视图可以计算它被按下的画面(值).
但是在这种情况下,当onTouchEvent没有调用Talkback启用方法时.只有当用户双击视图时才会调用.我试图添加自定义OnTouchListener但它不起作用.setFocusable=true和setFocusableInTouchMode=true.
我是D的新手,我在简单测试中将它与Java进行比较,并希望看到母语更快(或大致相同).但是在我第一次使用递归D的测试中,它比Java慢得多(差不多两次).
Java(这是糟糕的java性能测试,但它只是简单的想法):
public static void main(String... args) {
long before = System.nanoTime();
System.out.println(fibonacci(40));
System.out.println(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - before));
}
static int fibonacci(int n) {
if (n < 2) {
return n;
}
return fibonacci(n - 2) + fibonacci(n - 1);
}
Run Code Online (Sandbox Code Playgroud)
环境:Win7 64bit,JDK:1.7.0_10 x64.
d:
import std.stdio;
import std.datetime;
void main(string[] args)
{
auto r = benchmark!(simplebench)(1);
writefln("%s", r[0].to!("msecs", int));
}
void simplebench() {
writeln(fibonacci(40));
}
int fibonacci(int n) {
if (n < 2) {
return n;
}
return fibonacci(n - 2) …Run Code Online (Sandbox Code Playgroud) 我有IntentService应该通过绑定使用来自另一个服务的引用:
public class BaseIntentService extends IntentService implements ServiceConnection {
protected NetworkApi network;
public BaseIntentService() {
super("BaseIntentService");
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
network = ((NetworkApiBinder) service).getApi();
// never be invoked
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
@Override
public void onCreate() {
super.onCreate();
bindService(new Intent(this, NetworkApi.impl), this, BIND_AUTO_CREATE);
}
@Override
public void onDestroy() {
super.onDestroy();
unbindService(this);
}
@Override
protected void onHandleIntent(Intent intent) {
// network always null!!!
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我使用像这样的绑定时,onServiceConnected永远不会被调用.我知道IntentService不是为绑定模式而设计的,但是对于这样的任务可能有一个共同的解决方案吗?
谢谢!