[英]Switching orientation in Android
i have any troubles with switching between orientation from portrait to landscape. 我在从纵向到横向的方向之间切换时遇到了麻烦。
i made this page cause i don't have permission to add images 我做了这个页面因为我没有添加图像的权限
http://www.guitart.comyr.com/ http://www.guitart.comyr.com/
There are my codes and two images. 有我的代码和两个图像。
I've tried to make some small application to test switching, i made same folders as you can see at the page and this small test app works fine. 我试图制作一些小应用程序来测试切换,我创建了相同的文件夹,你可以在页面上看到这个小测试应用程序工作正常。 But my original app doesnt work.
但我原来的应用程序不起作用。
Sorry for English. 对不起英文。
Have you tried to just copy the layout file from layout folder and paste it in "layout-land". 您是否尝试从布局文件夹中复制布局文件并将其粘贴到“layout-land”中。 check the id's of the views because logcat is showing nullPointerException in onCreate.
检查视图的id,因为logcat在onCreate中显示nullPointerException。
Do you have 你有
<Button
android:id="@+id/btn_menu_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/info64"
android:src="@drawable/info64" />
in both menu.xml layouts(layout|layout-land) folders? 在两个menu.xml布局(layout | layout-land)文件夹中? If you change the orientation to landscape, your app automatically uses the xmls from your layout-land folder.
如果您将方向更改为横向,则您的应用会自动使用layout-land文件夹中的xmls。 Eclipse don't recognize if the ID exists in both orientations.
Eclipse无法识别两个方向中是否存在ID。 Eclipse can't stop you from building because it's no error but it could at least give you a warning imo.
Eclipse无法阻止你构建,因为它没有错误,但它至少可以给你一个警告imo。
No problem :) 没问题 :)
<Button
android:id="@+id/btn_menu_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/info64"
android:src="@drawable/info64" />
remove 去掉
android:src="@drawable/info64"
line from this button's property.thats the problem.and you are done. 从这个按钮的property.thats问题。你完成了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.