开发者

Android UI: New activity or new layout?

开发者 https://www.devze.com 2023-03-12 08:10 出处:网络
I\'m designing the interface for an application to display some data pulled from a database in a TableLayout.Right now, the default view is portrait orientation which consists of a drop down menu and

I'm designing the interface for an application to display some data pulled from a database in a TableLayout. Right now, the default view is portrait orientation which consists of a drop down menu and a table with three columns. When the user switches to landscape orientation, the spinner and its choices can stay the same, but I am going to be displaying an entirely different table (different column headings and more columns).

Something worth noting is that when the user picks an option from the drop down menu, a call to the database is made. All the data retrieved from this call is stored in an ArrayList, and this ArrayList also contains the info that will be displayed in landscape mode. My question is, would it be better to create the landscape design as entirely new activity, or simply just define it as a new layout? It seems to me that making a new activity would require a lot of redundant code and making the user wait unnecessarily for another web service call.

Here is the portrait layout:

Android UI: New activity or new layout?

Here is the lands开发者_如何学JAVAcape layout:

Android UI: New activity or new layout?

Note: the spinner from portrait mode will be present in the landscape layout as well, forgot to include it in the picture


Android makes it extremely easy to have separate layout files for the different orientations. If you simply add a layout-land folder to your project and add a new layout file with the same name as the one for portrait (but with the different UI elements you need) then the OS itself will automatically switch layouts depending on orientation.

All you need to do is check orientation in onCreate(...) and hold it as a Boolean (isPortrait for example) then each method responsible for updating the UI can simply check that to determine what components (table columns etc) need to be populated/updated.


I think having a new activity when changing from portrait to landscape is a bit too much. You should just use CSS3 media queries to alter how the table is displayed. Show more information with the use of floats or clears when on landscape. Use the responsive layout principles: http://www.alistapart.com/articles/responsive-web-design/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号