我想更改listView中的项之间的间距(也许我应该使用另一个View-element?)代码如下所示:
<ListView SelectionMode="None" HorizontalContentAlignment="Left" >
<ListView.Items>
<TextBlock Text="Item 1" />
<TextBlock Text="Item 2" />
<TextBlock Text="Item 3" />
<TextBlock Text="Item 4" />
</ListView.Items>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" HorizontalChildrenAlignment="left"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
Run Code Online (Sandbox Code Playgroud)
我想尽可能地模仿普通的stackpanel(wchich可以包装元素).目前项目之间的空间(水平空间)太大了.我之前的问题 - > Windows 8 WrapPanel
提前致谢
我有一个问题与我之前的问题有关.我想从混音器(扬声器)录制音频,我正在使用javax.sound.我必须设置audioFormat,我不知道在那里键入什么:/使用类ListMixer(我在这里找到 - > http://forums.oracle.com/forums/thread.jspa?threadID=2198477&tstart=2) ,我写这样的东西:http://forums.oracle.com/forums/thread.jspa?threadID = 21848477&tstart = 2,但我没有任何关于采样率的信息(未知采样率).程序抛出此异常:
java.lang.IllegalArgumentException:Line unsupported:interface TargetDataLine支持格式PCM_UNSIGNED 44100.0 Hz,8位,单声道,4字节/帧,
码:
package sound;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.sound.sampled.*;
public class AudioCapture02 extends JFrame{
boolean stopCapture = false;
ByteArrayOutputStream byteArrayOutputStream;
AudioFormat audioFormat;
TargetDataLine targetDataLine;
AudioInputStream audioInputStream;
SourceDataLine sourceDataLine;
public AudioCapture02(){//constructor
final JButton captureBtn =
new JButton("Capture");
final JButton stopBtn = new JButton("Stop");
final JButton playBtn =
new JButton("Playback");
captureBtn.setEnabled(true);
stopBtn.setEnabled(false);
playBtn.setEnabled(false);
//Register anonymous listeners
captureBtn.addActionListener(
new ActionListener(){ …Run Code Online (Sandbox Code Playgroud) 我有自动将StackPanel分解为下一行的问题.这是示例代码:
<StackPanel Orientation="Horizontal" Width="180">
<TextBlock.../>
<TextBlock.../>
<TextBlock.../>
<Image.../>
...
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
现在我想要达到这样的效果:当StackPanel中没有足够的空间用于另一个元素时,它应该放在新行中.我怎么能得到这个(没有必要使用stackpanel)?
PS:我的目标是将文本和图像放在一行中(当没有足够的空间用于另一个元素时,它当然可以中断).也许你可以提供比使用文本块和图像更好的解决方案?
我的本地化应用程序存在问题.我有文件Resources.resw,其中包含字符串"noResults.Text"(它以.Text结尾,因为我在xaml中使用它来处理textblock(x:Uid))问题是我想在代码后面使用相同的字符串( C#)我如何访问它?我尝试过这样的事情:
resourceLoader.GetString("noResults");
resourceLoader.GetString("noResults.Text");
Run Code Online (Sandbox Code Playgroud)
但这一切都没有
提前致谢 :)
我正在尝试从网站下载图像并根据该图像创建位图.它看起来像这样:
public void test()
{
PostWebClient client = new PostWebClient(callback);
cookieContainer = new CookieContainer();
client.cookies = cookieContainer;
client.download(new Uri("SITE"));
}
public void callback(bool error, string res)
{
byte[] byteArray = UnicodeEncoding.UTF8.GetBytes(res);
MemoryStream stream = new MemoryStream( byteArray );
var tmp = new BitmapImage();
tmp.SetSource(stream);
}
Run Code Online (Sandbox Code Playgroud)
我在回调方法的最后一行收到"未指定的错误".有趣的事实是,如果我使用BitmapImage(新的Uri("SITE"))它运作良好...(我不能这样做因为我想从该URL抓取cookie.图像是jpg.PostWebClient类- > http://paste.org/53413
函数声明之间的swift有什么区别:
func function(a: String) {
print(a);
}
function("test");
Run Code Online (Sandbox Code Playgroud)
和关闭分配:
let closure = {
(a: String) in
print(a);
}
closure("test");
Run Code Online (Sandbox Code Playgroud)
那些之间有什么区别吗?
我在python脚本中使用ctypes lib时遇到了麻烦.这是我的代码(在互联网上找到):
if __name__ == "__main__":
from ctypes import *
user32 = windll.user32
kernel32 = windll.kernel32
class RECT(Structure):
_fields_ = [
("left", c_ulong),
("top", c_ulong),
("right", c_ulong),
("bottom", c_ulong)];
class GUITHREADINFO(Structure):
_fields_ = [
("cbSize", c_ulong),
("flags", c_ulong),
("hwndActive", c_ulong),
("hwndFocus", c_ulong),
("hwndCapture", c_ulong),
("hwndMenuOwner", c_ulong),
("hwndMoveSize", c_ulong),
("hwndCaret", c_ulong),
("rcCaret", RECT)
]
def moveCursorInCurrentWindow(x, y):
# Find the focussed window.
guiThreadInfo = GUITHREADINFO(cbSize=sizeof(GUITHREADINFO))
user32.GetGUIThreadInfo(0, byref(guiThreadInfo))
focussedWindow = guiThreadInfo.hwndFocus
# Find the screen position of the window.
windowRect = RECT() …Run Code Online (Sandbox Code Playgroud) 我需要在应用程序清单中本地化一些数据(如名称,描述,闪屏图像等).根据文档,这些数据可以作为资源提供,但我不知道如何做到这一点.
我是新的emacs用户,其中一件令我恼火的事情是,当我想用剪贴板中的那个替换当前选定的文本时,我需要先删除它.我知道的每个其他应用程序默认情况下都会将粘贴的文本替换为当前选择.
这里有一个更详细的描述:
我试图建立一个电子邮件客户端,但它不起作用:/我试图用SSL连接谷歌imap(没有SSL,我可以做到)代码:
#include "StdAfx.h"
#include "openssl/ssl.h"
#include "iostream"
#include <cstdio>
#include <iostream>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <windows.h>
using namespace std;
#pragma comment(lib, "Ws2_32.lib")
#define BUFSIZE 1024
char buf[BUFSIZE];
char *msg;
WSADATA wsda;
int sock;
struct hostent *host;
struct sockaddr_in server_addr;
short int s_port = 993;
const char *s_ipaddr = "74.125.77.109";
int SSL_library_init();
SSL_METHOD *meth;
int main () {
SSL_load_error_strings();
SSL_library_init();
//RAND_seed(buf, BUFSIZE);
SSL_CTX *sslContext = SSL_CTX_new(SSLv23_client_method());
if (sslContext == NULL)
{
cout << "err\n";
}
SSL *sslConnection = …Run Code Online (Sandbox Code Playgroud) 我想让我的程序进入睡眠状态几秒钟.当我使用thread.sleep(x)整个程序没有响应.根据这篇文章 - > http://msdn.microsoft.com/en-us/library/hh184840(v=VS.92).aspx应用程序,不负责3秒不通过认证:/(我必须等待5秒钟).有人知道这个问题的解决方案吗?
从web复制的简单代码似乎不起作用.单击按钮时没有动作,但正确更改了文本.怎么了?
package android.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button closeButton = (Button)this.findViewById(R.id.button1);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Klik!", Toast.LENGTH_LONG);
}
});
closeButton.setText("dupa");
}
}
Run Code Online (Sandbox Code Playgroud)
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:layout_width="wrap_content" android:id="@+id/button1" android:layout_height="wrap_content" android:text="@string/button"></Button>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助,克里斯
我正在尝试使用WiFi将手机连接到笔记本电脑.两个设备都连接到一个网络.笔记本电脑有IP 192.168.1.35所以我试图通过智能手机连接该IP(防火墙已关闭).这是代码:
package org.me.androidapp;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
try {
Toast.makeText(this.getApplicationContext(), "OK", Toast.LENGTH_LONG).show();
Socket socket = new Socket("192.168.1.35", 9999);
PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);
out.println("dupa");
socket.close();
} catch (UnknownHostException ex) {
Toast.makeText(this.getApplicationContext(), "Nie odnaleziono hosta", Toast.LENGTH_LONG).show();
Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Toast.makeText(this.getApplicationContext(), …Run Code Online (Sandbox Code Playgroud)