首页 \ 问答 \ 如何包含一个大型GridView并仍能滚动?(How to contain a large GridView and still able to scroll?)

如何包含一个大型GridView并仍能滚动?(How to contain a large GridView and still able to scroll?)

如何实现大型GridView并能够垂直和水平滚动?

我可以垂直滚动但不能水平滚动。 水平宽度固定为父宽度,不能扩展大于父宽度。

以下屏幕截图是我想要实现的示例。

电影院座位预订


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.

Cinema Seat Reservation


原文:https://stackoverflow.com/questions/34726512
更新时间:2023-08-10 19:08

最满意答案

我使用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.

相关问答

更多
  • 当请求体已经通过在同一个servlet的doPost()方法内部或者doFilter()方法内的request上调用getParameter() , getReader()或getInputStream()方法预先解析请求体时,它将失败。其中一个servlet过滤器也在同一个请求上运行。 另一个可能的原因是您正在嵌套HTML
    元素,但行为依赖于浏览器。 顺便说一句,自1998年以来,HTML
    元素已被弃用 。摆脱它并使用CSS代替。 更新 :您的更新确认您正在request上调用 ...
  • 从堆栈跟踪中可以明显看出,您在类的第156行上取消引用的项目之一为空。 尽管我们在提供的代码片段中没有行号,但它看起来像是在upload.parseRequest行(您自己也认定为失败的部分)上真正可行。 奇怪的是,看起来只有upload为空时才会发生这种情况 - 但是从您给出的代码看起来这似乎是不可能的,因为它从构造函数中分配了一个非空值,只有几行,现在已经更改。 如果你可以附加一个调试器,然后逐步通过你的方法并检查对象值将是一个好主意。 否则,可能需要在该点之前放置几条println语句来验证哪些对象为 ...
  • 1)如何从应用程序/服务上传文件到servlet,换句话说,没有用户应填写的html表单? 您必须创建一个HTTP请求,其中包含包含您要上载的文件的正确标头(multipart / formdata)。 看看这篇文章:将文件从Java客户端上传到HTTP服务器 。 我没有尝试过,但它看起来好像可以工作。 2)在接收端,我之前使用过Apache FileUpload,但是它处理表单输入,还有另一种方法来处理不是来自表单的上传吗? 您仍然可以在接收端使用Apache FileUpload,因为它只解析仍应以相同 ...
  • 问题解决了! 这是一个错误的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 ...
  • 我终于可以成功地将请求从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 ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)