ViewStub


 

  1. Static ViewStub
  2. Dynamic ViewStub

 

1. Static ViewStub
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open res -> layout -> Create new layout, subtree.xml and add following code :

 

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

viewstub viewstub2 viewstub3

Download_button

 

2. Dynamic ViewStub
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open src -> package -> MainActivity.java and add following code :

Step 3 : Open res -> layout -> Create new layout, subtree.xml and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

dy_viewstub dy_viewstub2 dy_viewstub3

Download_button