如何包含一个大型GridView并仍能滚动?(How to contain a large GridView and still able to scroll?)
How can I achieve having a large GridView and able to scroll vertically and horizontally?
I am able to scroll vertically but not horizontally. The horizontal width is fixed to the parent width and can't expand larger than the parent width.
The following screenshot is the example I want to achieve.
原文:https://stackoverflow.com/questions/34726512
最满意答案
我使用Wireshark来查看浏览器实际发送的内容。 它接缝(在其他内容之外),在Content-Disposition(例如“Content-Type:application / pdf \ r \ n \ r \ n”之后)发送另一个Content-Type标头(在“MIME Multipart Media Encapsulation”部分中) \ n“。所以,在文件上传教程中,在以下行之后:
dos.writeBytes("Content-Disposition: form-data;name=\"uploadedfile\";" + "filename=\"" + fileName + "\"" + lineEnd);
我刚补充说:
String mimeType = URLConnection.guessContentTypeFromName(file.getName()); dos.writeBytes("Content-Type: " + mimeType + lineEnd);
现在它接缝上传过程工作正常。
当然,对于许多扩展,mimeType可能为null,因此应根据需要进行检查。
I used Wireshark to view what was the browser actually sending. It seams that (among other stuff), another Content-Type header is sent (in the "MIME Multipart Media Encapsulation" section), after Content-Disposition (for ex. "Content-Type: application/pdf\r\n\r\n". So, in the file upload tutorial, after the following line:
dos.writeBytes("Content-Disposition: form-data;name=\"uploadedfile\";" + "filename=\"" + fileName + "\"" + lineEnd);
I just added:
String mimeType = URLConnection.guessContentTypeFromName(file.getName()); dos.writeBytes("Content-Type: " + mimeType + lineEnd);
Now it seams the uploading process is working fine.
Of course, for many extensions, mimeType will probably be null, so it should be checked, according to needs.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
当请求体已经通过在同一个servlet的doPost()方法内部或者doFilter()方法内的request上调用getParameter() , getReader()或getInputStream()方法预先解析请求体时,它将失败。其中一个servlet过滤器也在同一个请求上运行。 另一个可能的原因是您正在嵌套HTML
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
java servlet中的Apache Commons fileUpload问题(Apache Commons fileUpload problem in java servlet)[2023-11-16]
从堆栈跟踪中可以明显看出,您在类的第156行上取消引用的项目之一为空。 尽管我们在提供的代码片段中没有行号,但它看起来像是在upload.parseRequest行(您自己也认定为失败的部分)上真正可行。 奇怪的是,看起来只有upload为空时才会发生这种情况 - 但是从您给出的代码看起来这似乎是不可能的,因为它从构造函数中分配了一个非空值,只有几行,现在已经更改。 如果你可以附加一个调试器,然后逐步通过你的方法并检查对象值将是一个好主意。 否则,可能需要在该点之前放置几条println语句来验证哪些对象为 ... -
从另一个应用程序/服务上载和处理文件到servlet(Uploading and handling a file to a servlet from another application/service)[2022-12-05]
1)如何从应用程序/服务上传文件到servlet,换句话说,没有用户应填写的html表单? 您必须创建一个HTTP请求,其中包含包含您要上载的文件的正确标头(multipart / formdata)。 看看这篇文章:将文件从Java客户端上传到HTTP服务器 。 我没有尝试过,但它看起来好像可以工作。 2)在接收端,我之前使用过Apache FileUpload,但是它处理表单输入,还有另一种方法来处理不是来自表单的上传吗? 您仍然可以在接收端使用Apache FileUpload,因为它只解析仍应以相同 ... -
多个dex文件定义了Lorg / apache / commons / io / IOUtils;(Multiple dex files define Lorg/apache/commons/io/IOUtils;)[2021-10-21]
问题解决了! 这是一个错误的commons-io依赖。 这个失败的原因可以在这里找到: maven依赖org.apache.commons:commons-io和commons-io:commons-io有什么区别? 只需更换 实现'org.apache.commons:commons-io:1.3.2' 同 实施'commons-io:commons-io:1.3.2' Problem solved! It was a wrong commons-io dependecy. The reason for ... -
使用apache fileupload将文件从applet上传到servlet(Upload file from applet to servlet using apache fileupload)[2023-07-21]
我终于可以成功地将请求从applet发布到servlet了。 我错过了一个简单的逻辑。 我没有添加标题和预告片,同时发送到servlet,这是密钥,在servlet中将传入的请求标识为多部分数据。 FileInputStream fileInputStream = new FileInputStream(new File( fileEntry)); dataOutputStream.writeBytes(twoHyphens + bou ... -
我使用Wireshark来查看浏览器实际发送的内容。 它接缝(在其他内容之外),在Content-Disposition(例如“Content-Type:application / pdf \ r \ n \ r \ n”之后)发送另一个Content-Type标头(在“MIME Multipart Media Encapsulation”部分中) \ n“。所以,在文件上传教程中,在以下行之后: dos.writeBytes("Content-Disposition: form-data;name=\"u ...
-
您对toString()的调用最终会转发给copyLarge() 。 在这里,您可以看到继续从流中读取,直到InputStream.read()检测到文件结束(EOF)标记。 根据这篇文章, read()可以读取0个字节,也就是说,如果你读取的URLConnection没有返回EOF标记,那么该方法可能会永远读取0个字节。 也许您可以追踪导致问题的URL? 无论如何,要实现超时,您可以在单独的线程中开始每次读取并在经过一段时间后终止该线程。 I've decided to try simply using ...
-
它不知道你是从HTTP服务器读取的。 All is has是一个输入流,它所能做的就是跳到你指定的偏移量。 如果您希望服务器执行此操作,您需要查看自己设置HTTP Range:标头。 It doesn't know you're reading from an HTTP server. All is has is an input stream, and all it can do with that is skip to the offset you specify. If you want the se ...