在Java中,我们有Collections.emptyList()和Collections.EMPTY_LIST.两者都具有相同的属性:
返回空列表(不可变).此列表是可序列化的.
那么使用这一个或另一个之间的确切区别是什么?
如何将自定义滤镜应用于相机输出中的单个帧,并显示它们.
到目前为止我尝试过的:
mCamera.setPreviewCallback(new CameraGreenFilter());
public class CameraGreenFilter implements PreviewCallback {
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
final int len = data.length;
for(int i=0; i<len; ++i){
data[i] *= 2;
}
}
}
Run Code Online (Sandbox Code Playgroud)
虽然它的名字包含"绿色",但我实际上只是想以某种方式修改这些值(在这种情况下,颜色会稍微加强一些).长话短说,它不起作用.
我发现字节数组'data'是摄像头输出的副本; 但这并没有真正帮助,因为我需要'真正的'缓冲区.
我听说你可以用openGL来实现它.这听起来很复杂.
有没有更简单的方法?否则,这个openGL-surfaceView映射将如何工作?
可能重复:
访问python int literals方法
在Python中everything is an object.
但话又说回来,为什么下面的代码片段不起作用?
1.__add__(2)
Run Code Online (Sandbox Code Playgroud)
但是,这确实有效:
n = 1
n.__add__(2)
Run Code Online (Sandbox Code Playgroud)
n和之间有什么区别1?
这不是一个设计失败,它不起作用?例如,它也适用于string文字.
"one".__add__("two")
Run Code Online (Sandbox Code Playgroud)
相比之下,它也适用于其他纯面向对象的语言.
让我们仔细看看这个编译c#示例:
Console.WriteLine(100.ToString());
Run Code Online (Sandbox Code Playgroud)
那么,Python从什么C#角度来区别everything is an object?
问题是"如何将ScrollView向上滚动到非常平滑和缓慢".
在我的特殊情况下,我需要在大约1-2秒内滚动到顶部.我已经尝试使用Handler手动插值(调用scrollTo(0,y)),但这根本不起作用.
我已经在一些书籍阅读器应用程序上看到了这种效果,所以必须有一种方法,我确定:D.(文本非常慢地向上滚动以继续阅读而不触摸屏幕,进行输入).
我有时会看到人们使用这种Activity.onAttachedToWindow方法,但我个人从未使用过它.在阅读它的文档时,它在我看来就像它几乎一样onStart().
我假设的一件事是:
onAttachedToWindow在onCreate()
onStop之后调用之前调用.
我对这个假设是对的吗?什么是两者的代表什么,你什么时候使用哪个?
我想将所有被包围的-字符串替换为括在其中的字符串~,但是如果该字符串再次被括起来则不能*.
举个例子,这个字符串......
The -quick- *brown -f-ox* jumps.
Run Code Online (Sandbox Code Playgroud)
......应该成为......
The ~quick~ *brown -f-ox* jumps.
Run Code Online (Sandbox Code Playgroud)
我们看到-只有在不在内的情况下才会被替换*<here>*.
我现在的javascript-regex(不管它是否被括起来都不关心*):
var message = source.replace(/-(.[^-]+?)-/g, "~$1~");
Run Code Online (Sandbox Code Playgroud)
编辑:请注意,可能存在奇数个*s.
我想检查是否(如果是,并且,如果是(x,y),则仅用于突出显示)路径确实与自身相交.如何检查路径是否与另一条路径相交也是非常有趣的.这是一个截图,以更好地解释我的意思:
我最近安装了Haskell Eclipse插件"EclipseFP".一切都很好,而有一个功能让我很生气呵呵.我无法降低输出的警告级别.Eclipse/It的插件似乎会自动附加"-Wall"标志,这对于类型事物非常敏感.让我们以一个例子来说明这个:
*Main> head [1,2,3]
<interactive>:1:11:
Warning: Defaulting the following constraint(s) to type `Integer'
(Num a0) arising from the literal `3'
In the expression: 3
In the first argument of `head', namely `[1, 2, 3]'
In the expression: head [1, 2, 3]
<interactive>:1:11:
Warning: Defaulting the following constraint(s) to type `Integer'
(Num a0) arising from the literal `3' at <interactive>:1:11
(Show a0) arising from a use of `print' at <interactive>:1:1-12
In the expression: 3
In the first argument …Run Code Online (Sandbox Code Playgroud) 我的应用程序目前如下所示.Buttona RelativeLayout中有三个s ,中间按钮左右边距为负,与其他两个按钮重叠.
问题:当我单击左侧或右侧按钮时,它会到达前景一秒钟并重叠中间按钮,这看起来非常难看.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<Button
android:id="@+id/voices"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:onClick="clickVoices"
android:background="#333"
android:textColor="#fff"
android:text="@string/main_voices" />
<Button
android:id="@+id/chat"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:onClick="clickChat"
android:background="#333"
android:textColor="#fff"
android:text="@string/main_chat" />
<Button
android:id="@+id/record"
android:layout_width="60dp"
android:layout_height="100dp"
android:clickable="true"
android:onClick="clickRecord"
android:scaleType="centerInside"
android:src="@drawable/record"
android:text="Record"
android:layout_toRightOf="@+id/voices"
android:layout_toLeftOf="@+id/chat"
android:layout_marginLeft="-20dp"
android:layout_marginRight="-20dp"
android:layout_marginTop="-30dp"
android:background="@drawable/round_button"
android:paddingTop="30dp"
android:layout_marginBottom="10dp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我尝试制作类似于GMail使用的图像上传功能.您从桌面复制(CTRL-C)图像并将其粘贴(CTRL-V)到网站上.然后通过XMLHttpRequest将图像上传到处理传入文件的php脚本,其中"处理"意味着重命名并存储在服务器上.
我已经可以获取图像(和-data),但我无法成功提交和接收XMLHttpRequest.我的Javascript代码看起来像这样:
document.onpaste = function(e){
var items = e.clipboardData.items;
console.log(JSON.stringify(items));
if (e.clipboardData.items[1].kind === 'file') {
// get the blob
var imageFile = items[1].getAsFile();
console.log(imageFile);
var reader = new FileReader();
reader.onload = function(event) {
console.log(event.target.result); // data url!
submitFileForm(event.target.result, 'paste');
};
}
};
function submitFileForm(file, type) {
var formData = new FormData();
formData.append('file', file);
formData.append('submission-type', type);
var xhr = new XMLHttpRequest();
xhr.open('POST', 'php/image-upload.php');
xhr.onload = function () {
if (xhr.status == 200) {
console.log('all done: ');
} else {
console.log('Nope');
} …Run Code Online (Sandbox Code Playgroud)