当方向改变时如何改变布局
当我从纵向模式转到横向模式时,我想更改我的黑莓屏幕 GUI。
protected void sublayout(int width, int height) {
// TODO Auto-generated method stub
if(Display.getOrientation()==Display.DIRECTION_PORTRAIT)
{
label.setText("Portrait");
}
else
{
label.setText("Landscape");
}
super.sublayout(width, height);
}
任何帮助将不胜感激
I want to change my blackberry screen GUI When i go from portrait to landscape mode.
protected void sublayout(int width, int height) {
// TODO Auto-generated method stub
if(Display.getOrientation()==Display.DIRECTION_PORTRAIT)
{
label.setText("Portrait");
}
else
{
label.setText("Landscape");
}
super.sublayout(width, height);
}
any help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
覆盖 sublayout ,每当方向发生变化时都会调用它,以便您可以使用它来添加/删除/更改字段。
您还可以使用 Display.getOrientation() 来检查当前方向。您还应该跟踪应用程序中之前的方向,以防因其他原因调用子布局。
Override sublayout on your screen, this is called whenever the orientation changes so you can use it to add/remove/change fields.
You can also use Display.getOrientation() to check the current orientation. You should also track the previous orientation within your application in case sublayout was called for a different reason.
您需要手动处理它。每当黑莓中的方向发生变化时,它都会调用 subLayout() 方法。在那里你可以调用 invalidate 方法来刷新你的屏幕。但请确保您使用的是相对布局而不是绝对布局。它将自动排列屏幕中的 UI 元素。
You need to handle it manually. Whenever orientation changes in blackberry it calls the subLayout() method. There you can call invalidate method which will refresh your screen. But make sure that you are using relative layout instead of absolute layouts. It will automatically arrange the UI elements in your screen.