What is the difference between view and activity in android development?

The "right" way to do it is to use Activity for each screen and use the <include> tag for the menu you would like to be in all screens.

This way you will have the "back" button act as it should be and it would be easier for you to handle when switching screens.

To use the , you should put the things you want to reuse into extra files. Then you can use it as follows:

<!-- my_header.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/text01"/>

In another file include it with:

<include layout="@layout/my_header" />
<!-- your other stuff -->

You should create separate activities for you screens. Android handles the back button of the device by popping the current activity out from the stack and displaying the last one. So if for example the user wants to return to screen 2 for another selection, the back button does this.


activity is like canvas where you put your drawing as view.Yes you can set all above four view in single activity but it will depend how you handle it and does your app needs it to be done like this.


A View in Android is a widget that displays something. Buttons, listviews, imageviews, etc. are all subclasses of View. When you say "change view" I assume you mean change the layout by using setContentView(). This usually only needs to be done once per activity. An Activity is basically what you are referring to as a screen. To answer your question, it sounds like you need four separate activities (one for each screen).

Tags:

Android