我想为jquery ajax响应下载pdf文件.Ajax响应包含pdf文件数据.我试过这个解决方案.我的代码如下,但我总是得到一个空白的pdf.
$(document).on('click', '.download-ss-btn', function () {
$.ajax({
type: "POST",
url: 'http://127.0.0.1:8080/utils/json/pdfGen',
data: {
data: JSON.stringify(jsonData)
}
}).done(function (data) {
var blob = new Blob([data]);
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = "Sample.pdf";
link.click();
});
});
Run Code Online (Sandbox Code Playgroud) 我正在使用带有NodeJS后端的Google Cloud API for Speech-to-text.应用程序需要能够侦听语音命令,并将它们作为缓冲区传输到后端.为此,我需要在检测到静音时发送前一个音频的缓冲区.
任何帮助,将不胜感激.包括下面的js代码
if (!navigator.getUserMedia)
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true}, success, function (e) {
alert('Error capturing audio.');
});
} else alert('getUserMedia not supported in this browser.');
var recording = false;
window.startRecording = function () {
recording = true;
};
window.stopRecording = function () {
recording = false;
// window.Stream.end();
};
function success(e) {
audioContext = window.AudioContext || window.webkitAudioContext;
context = new audioContext();
// the sample rate is in …Run Code Online (Sandbox Code Playgroud) javascript node.js audiocontext web-audio-api google-cloud-speech
我正在使用ActionBarSherlock开发一个App
菜单中的一个项目是矩形图像.看它的xml:
<item
android:id="@+id/kapturar_action"
android:showAsAction="always"
android:icon="@drawable/camera_action_icon"
android:title="@string/kapturar" />
<item
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.问题是SDK 4.3似乎只接受方形图像(这是我的假设,我不确定),图标以一种奇怪的方式显示,保留了似乎是"最大宽度"的属性.
请参阅版画屏幕
Android 2.2 - 模拟器:

Android 4.1.2 - 三星Galaxy S3 Mini:

Android 4.3 - Nexus 4:

我仔细检查了drawables,我认为一切都是正确的.我已经定义了MDPI,HDPI和XHDPI图像.
任何人都可以肯定在菜单项目中不可能使用矩形抽屉吗?有没有办法解决Android 4.3中的问题,保留向后兼容?
我试图通过样式扩大我的所有应用程序对话框按钮上的文本大小.以下代码将更改按钮背景颜色甚至文本大小写,但由于某种原因,textSize项目不符合:
<style name="MyAppTheme" parent="@android:style/Theme.Holo">
<item name="android:dialogTheme">@style/MyApp.Dialog</item>
<item name="android:alertDialogTheme">@style/MyApp.Dialog.Alert</item>
</style>
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>
<style name="MyApp.Dialog.Alert" parent="@style/MyApp.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="MyApp.BorderlessButton" parent="@android:style/Widget.Holo.Button.Borderless">
<item name="android:textSize">50sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:background">#800</item>
</style>
Run Code Online (Sandbox Code Playgroud)

为什么没有读取textSize?我需要做些什么来扩大它?
android android-layout android-theme android-dialog android-styles
我在滚动视图中有一个listview,在此之前几乎有一页滚动,但是一旦我的listview被填充,滚动视图就会移动到列表视图的顶部.我该如何解决这个/防止这种情况发生?
滚动视图XML:
<ScrollView
android:id="@+id/tvscrollview"
android:layout_marginTop="8.0dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
layout="@layout/a" />
<include
layout="@layout/b" />
<include
layout="@layout/c" />
<include
layout="@layout/d" />
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我试过做sv.fullScroll(ScrollView.FOCUS_UP); 以及所有那些东西到我的scrollview但它不起作用
我有一个图像按钮,其宽度和高度在xml文件中指定.但我想用屏幕尺寸的设备更改它.
如何以编程方式设置ImageButton的宽度,高度和边距?
我想评估复选框是否已从扫描图像中选中.我发现节点模块就像node-dv和node-fv一样.但是什么时候安装它我在mac上遇到以下错误.
../deps/opencv/modules/core/src/arithm1.cpp:444:51: error: constant expression evaluates to 4294967295 which cannot be narrowed to type 'int' [-Wc++11-narrowing]
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
^~~~~~~~~~
../deps/opencv/modules/core/src/arithm1.cpp:444:51: note: insert an explicit cast to silence this issue
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
^~~~~~~~~~
static_cast<int>( )
../deps/opencv/modules/core/src/arithm1.cpp:444:75: error: constant expression evaluates to 4294967295 which cannot be narrowed to type 'int' [-Wc++11-narrowing]
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, …Run Code Online (Sandbox Code Playgroud) 我在音频处理时将 Int16Array 缓冲区发送到服务器
var handleSuccess = function (stream) {
globalStream = stream;
input = context.createMediaStreamSource(stream);
input.connect(processor);
processor.onaudioprocess = function (e) {
var left = e.inputBuffer.getChannelData(0);
var left16 = convertFloat32ToInt16(left);
socket.emit('binaryData', left16);
};
};
navigator.mediaDevices.getUserMedia(constraints)
.then(handleSuccess);
Run Code Online (Sandbox Code Playgroud)
在服务器中我尝试保存文件如下
client.on('start-audio', function (data) {
stream = fs.createWriteStream('tesfile.wav');
});
client.on('end-audio', function (data) {
if (stream) {
stream.end();
}
stream = null;
});
client.on('binaryData', function (data) {
if (stream !== null) {
stream.write(data);
}
});
Run Code Online (Sandbox Code Playgroud)
但这不起作用,那么我如何将此数组缓冲区保存为 wav 文件?
这是我的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main"
android:background="@android:color/black" >
<RelativeLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageButton
android:id="@+id/calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/about"
android:layout_centerHorizontal="true"
android:background="@drawable/calendar" />
<ImageButton
android:id="@+id/okan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/calendar"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/calendar"
android:background="@drawable/okanliyiz"/>
<ImageButton
android:id="@+id/about"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginTop="140dp"
android:layout_toLeftOf="@+id/calendar"
android:background="@drawable/info" />
</RelativeLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false" />
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我写了它的程序化部分和Drawer工作就好了,只是我不能点击它背后的ImageButtons .如果我把按钮放在前面我可以点击它们,但是抽屉被留下了,这是一个可怕的景象.这是什么解决方案?我怎样才能点击抽屉后面的按钮并看到前面的抽屉?
提前致谢.
android imagebutton android-layout navigation-drawer drawerlayout
我使用android支持库实现选项卡布局,它看起来像
这里标签宽度不适合屏幕,我的布局是
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我想在取消按钮时取消下载请求.现在当我按下代码工作下载按钮
@IBAction func downloadButtonPressed(sender: UIButton) {
var fileName = noticeAttacchment[0]["fileName"] as! String
var fileUrl = noticeAttacchment[0]["fileUrl"] as! String
if var URL = NSURL(string: fileUrl){
Api.load(URL, fileName: fileName)
}
}
Run Code Online (Sandbox Code Playgroud)
我的下载课程是
class Api {
class func load(URL: NSURL , fileName : String) {
let sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: sessionConfig, delegate: nil, delegateQueue: nil)
let request = NSMutableURLRequest(URL: URL)
request.HTTPMethod = "GET"
let task = session.dataTaskWithRequest(request, completionHandler: { (data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in
if (error …Run Code Online (Sandbox Code Playgroud) 我正在创建自定义平行四边形视图,并且视图使用默认偏移值渲染得很好。但是当我改变 ib 的偏移值时它不起作用
@IBDesignable class CustomParallelogramView: UIView {
@IBInspectable var offset: Float = 10.0
var path = UIBezierPath()
lazy var shapeLayer: CAShapeLayer = {
let layer = CAShapeLayer()
layer.path = path.cgPath
return layer
}()
override init(frame: CGRect) {
super.init(frame:frame)
drawParallelogram()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder:aDecoder)
drawParallelogram()
}
override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
drawParallelogram()
}
override func layoutSubviews() {
super.layoutSubviews()
updateFrame()
}
func drawParallelogram() {
print(offset)
path.move(to: CGPoint(x: bounds.minX + CGFloat(offset), y: bounds.minY))
path.addLine(to: CGPoint(x: bounds.maxX, y: bounds.minY))
path.addLine(to: …Run Code Online (Sandbox Code Playgroud) android ×6
javascript ×4
node.js ×3
swift ×2
ajax ×1
audiocontext ×1
buffer ×1
c++ ×1
drawerlayout ×1
fs ×1
imagebutton ×1
ios ×1
java ×1
jquery ×1
nsurlsession ×1
ocr ×1
pdf ×1
uiview ×1
wav ×1