简体   繁体   English

如何在不同的活动(如Android中的标签页)之间切换?

[英]How to switch between different activities like tabs in android?

在此处输入图片说明

I need to develop an application which contain these tabs shown in the image. 我需要开发一个包含图像中显示的这些选项卡的应用程序。 Each tab contain a form which will be filled by the user.User can switch to any tab. 每个标签页都包含一个表格,用户可以填写。用户可以切换到任何标签页。

User click Activity1, Activity 1 gets displayed and user enters some data; 用户单击“ Activity1”,将显示“ Activity 1”,并输入一些数据; then user press Activity 2, activity 2 gets displayed, user press Activity1 again, Activity 1 gets displayed with the data entered by the user(not the blank activity). 然后显示用户按下活动2,显示活动2,再次按下活动1,显示活动1,其中包含用户输入的数据(非空白活动)。

At the end when user click "Save" I need to get all the data from these activities and save it somewhere. 最后,当用户单击“保存”时,我需要从这些活动中获取所有数据并将其保存在某处。

I have worked a lot in java but new to android, I am stuck in developing the UI for this scenario. 我在Java方面做了很多工作,但对Android还是陌生的,我一直在为这种情况开发UI。 However I have done this many times in iOS. 但是,我在iOS中做了很多次。

Anybody please share your experience of developing such UI. 任何人都请分享您开发此类UI的经验。

Thanks, 谢谢,

Fragments will be more suitable for this scenario, the benefit are 片段将更适合这种情况,其好处是

  1. They are light weight and faster 它们重量轻且速度更快

  2. Managed automatically by the FragmentManager. 由FragmentManager自动管理。

  3. Data Sharing between Fragments is smoother and simpler than it is for Activities 片段之间的数据共享比“活动”更流畅,更简单

  4. They don't complicate the Architecture of the Application 它们不会使应用程序的架构复杂化

You can have as many Fragments as you want in you Activity. 您可以在“活动”中具有任意数量的片段。 Following two links can be useful for you. 以下两个链接可能对您有用。

A similar Thread 一个类似的线程

A Good Tutorial 一个好的教程

Another good tutorial 另一个很好的教程

If even after that you decide to use Activities, You need to think 即使在此之后您决定使用“活动”,也需要考虑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM