Activities vs. Fragment Implementation

安稳与你 提交于 2019-12-07 08:06:03

问题


I am having some trouble working with Activities and Fragments. I am in the early stages of app development and am ultimately looking to design the most efficient way of integrating two separate screens.

The first screen would be the "Splash Screen", It would present the user with the Logo, the ability to enter user information and sign in through either a database or with Facebook. There would also be a button available to allow the user to register for the app.

The second screen would allow the user to set up an account by defining his user information and would include a register button and also a connect with Facebook button.

I would like to know how everyone would approach the task at hand as I had initially designed the app designating 2 Activities to handle each screen. Recently, I have switched to being able to host the screens as 2 fragments under 1 Activity.

What are the benefits of each approach and which design would you opt for?


回答1:


Fragments are mainly for allowing you to display two separate UIs side-by-side on large-format devices. Fragments can combine code and UI within a single layout, and they also allow non-UI "activities", but mostly they give you flexibility in showing the various views attached to an activity.

I'd choose 2 activities, since what you're describing is a progression of operations rather than multiple views into the same operation.



来源:https://stackoverflow.com/questions/18500438/activities-vs-fragment-implementation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!