Javascript 生成的屏幕方向信息不会在 Android 模拟器中显示
我正在使用 Pro Android Web Apps 学习 Android 开发(Apress,作者:Damon Oehlman 和 Sebastien Blanc)。我在第二章遇到了障碍(如果我已经遇到麻烦了,这不是一个好兆头)。我在 Apress 网站上找不到这本书的任何帮助,所以我希望你们能在这里帮助我。
本章让我构建了一个 html、css 和 js 文件,这些文件应该在用户旋转设备时检测并显示设备的方向(旋转设备,即:))。
当我在本地 WAMP 服务器上运行的 Android 模拟器中运行代码时,页面显示正常(我认为 css 不太正确,但这没什么大不了的),但有关方向的数据没有显示根本不。我确保 js 文件的链接是正确的,我什至从 Apress 网站下载了所有三个文件,看看它是否在我的代码中,但这些也不起作用。本书的代码是为 v2.1 编写的。
我已在此处发布了三个文件的代码。由于我正在使用本地 WAMP 服务器完成这本书,所以我真的不知道如何让别人更容易地获取文件并自己测试它们。对不起。
我真的希望有人能看一下代码并帮助我。我真的很感激,这样我就可以继续完成这本书了!
谢谢!
[编辑] 我刚刚弄清楚如何更改模拟器中的方向,并且显示确实旋转,但同样,js 应该生成的输出不会在项目符号后面显示。
I'm learning Android development using Pro Android Web Apps (Apress, Auths: Damon Oehlman & Sebastien Blanc). I ran into a snag in the second chapter (not a good sign if I'm having trouble already). I couldn't find any help from the Apress site on the book, so I'm hoping you guys can help me out here.
The chapter has me build an html, css, and js file that are supposed to detect and display the orientation of the device as the user rotates it (rotates the device, that is :) ).
When I run the code in an Android emulator running on my local WAMP server, the page displays ok (I don't think the css is quite right, but that's no big deal), but the data regarding the orientation isn't being displayed at all. I made sure the link to the js file is correct, and I've even downloaded all three files from the Apress site to see if it's something in my code, but those won't work either. The book's code is written for v2.1.
I have posted the code for the three files here. Since I'm working through the book using a local WAMP server, I don't really know how to make it easier for someone to take the files and test them his/herself. Sorry.
I really hope someone can take a look at the code and help me out. I'd really appreciate it, so I can continue on working through the book!
Thanks!
[Edit]
I just figured out how to change the orientation in the emulator and the display does rotate, but again, the output that the js is supposed to generate isn't displaying after the bulleted items.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无能为力,但建议您使用实际设备来完成此类操作。如果您仍希望使用模拟器,请确保选择 Android 2.1 作为操作系统。您还可以使用
Log.d("tagname","line to be displayed");
使用System.out.println
的等效项进行调试,它将在DDMS(如果您使用的是 Eclipse,可以通过选择“Window”->“View Perspective”->“Other”->“DDMS”来查看,这将真正帮助您更多地调试此问题!I can't help too much but recommend that you use an actual device for things like this. If you still wish to use the emulator, make sure you choose Android 2.1 for the OS. You can also debug using the equivalent of
System.out.println
by usingLog.d("tagname","line to be displayed");
which will display lines onto DDMS (which if you're using Eclipse can be seen by selectingWindow -> View Perspective -> Other -> DDMS
which will really help you debug this problem more!