programming structure in android

well know we are familiar with android basics so we are moving forward with the programming structure of android .

THE main folder we will see on the top when we will start our new project is the app folder .

IN app folder we will have sub folders like

  • manifest
  • java
  • res
1) manifest folder
IN manifest folder we will find androidmanifest.xml file which is configuration file it contains several permissions icons and a an activity which you want as a startup activity.

2) java folder
In java folder there will be collection of all java files together .

3) res folder
 In res that is recourse folder has its sub folders such as
  • layout
  • drawable
  • values
Layout that is just in java we have different layouts android also supports some rich Layouts in which first we have linear layout  in which we have to set orientation that has two values one is vertical and other is horizontal keeps controls linearly vertical wise or horizontal wise .

Next we have Relative layout here it maps relative x and y position from the top of screen and places control relatively.

Moving on to Drawable folder just in java we have images folder in net beans here we have drawable folder which contains collection of different images.

Programming

we have two files in android one is the java file and other is the xml file for example our xml file's name is activity_main.xml  and java file name is MainActivity .

Now if you want to add a button in your xml file just you can add by

<?xml......
<RelativeLayout
  <button android:id="@+id/x"----->see how id is given in android.
      androidtext"ok"-------------->text given to button
      android_Layout_width:="in dp"
      android_Layout_height="in dp"
/>


NOTE: android studio builds a default class  R and all the other class are sub class to it .

NOW we will move on to java file

Structure of java file .....

class MainActivity extends Activity OR AppCompactActivity
{
    Button b1------> as we have taken a button in our xml file .
    void onCreate(bundle x)--------> this is the first method which will be called so all startup activity will start from here

super.onCreate(x)--->this calls the base class create with bundle object bundle binds the two activity.

}

THE ABOVE FILE INDICATED THE STRUCTURE OF JAVA FILE ...!!

IN THE NEXT POST WE WILL SEE HOW TO ACCESS THE CONTROLS BY THEIR ID ...!!

KEEP READING....!!



  








 

Comments

Popular posts from this blog

State space search / blocks world problem by heuristic approach /TIC TAC TOE

Navigation in Vaadin.

Drag and drop items from one Grid to another