Android Multi-Screen Application

How do you handle multiple screens in an Android app? I developed using the tab bar below without problems, however, what I want to do is replace all the content on the screen with the content from the new .xml layout file that I created in the project. Also, how would I link the end code to a new layout file? I am sure that this question probably already exists and is googleable (maybe it made a new word). However, I do not know what exactly I am looking for. Thanks in advance for your help.

+6
source share
4 answers

What you need to do is create a new action and add it to AndroidManifest.xml:

<activity android:name="ActivityClassName" android:label="Label for the Activity"></activity> 

and can be called in a method:

 public void startActivity() { Intent someName = new Intent(CurrentClass.this, ActivityClassName.class); startActivity(someName); } 
+6
source

Android applications typically use a separate action for each screen and switch between them using Activity.startActivity and Activity.startActivityForResult . You can pass arbitrary data to Activity through Intent.putExtra .

Hope this helps,

Phil Lello

+5
source

It really depends on how you want your application to flow.

Consider a scenario in which a user does the following:

  • Begins your first action.
  • Click the second tab
  • Click on the third tab.
  • Presses the back button

If you use a separate action for each screen, the following will happen:

  • Action 1 starts
  • Action 2 starts
  • Action 3 starts
  • Action 3 is closed, the user returns to Activity 2

(in this case, return the "Back" button again, you will return to "Activity 1", and press it again).

If you used one action for all tabs, the following will happen:

  • Action 1 starts
  • Step 1 sets the contents of the tab for the contents of tab 2.
  • Step 1 sets the contents of the tab for the contents of the tab 3.
  • Step 1 is closed, the user returns to the main screen

If you use a tabbed screen, the second method is preferred (one action with TabHost or similar), otherwise the user will end up making a large stack of activity simply by switching between tabs (that is, if they switch between tabs a lot, they will have to click the button repeatedly "Back" to exit).

If you want to move on to one approach to work, do some research on TabHost and TabContentFactory . In your factory's createTabContent method, you can inflate the view / layout from XML to set it as the contents of the tab using View.inflate . Look at them and come back, ask another question if you are stuck;)

+5
source

I think you can play with several actions .... you can have several actions and one xml for each of them ... so you can have different screens ... check these links. A few steps , creating an object .... hope this helps ...

+4
source

Source: https://habr.com/ru/post/885433/


All Articles