Online Tutorials & Training Materials | STechies.com
Register Login

Basic Overview of Android Project

|| || 0

Basic Overview of Android Project
Stechies

 Android Project Overview

The image below shows how an Android app project looks like

But what is what in this project? For example, the screen above image is called an activity. And the formal definition of an activity is an activity is a single focused thing that the user can do. Or in its simple terms, you can say that an activity is a screen, which users interact with. And an Android app can contain many activities in itself. Now where are these activities stored?

<xml version="1.0" encoding="utf-8"?>
<maifest xmlns:android="http://Schemas.android.com/apk/res/android"
  package="com.example.programmingknowledge.thrfirstapp">
<application
    android:allowBackup="true"
    android:"@drawable/ic_launcher"
    android:label=:string/app_name"
    android:theme="@style/AppTheme">
    <activity
         android:name=".MainActivity"
         android:label="TheFirstApp">
         <intent-filter>
             <action android:name="anroid.intent.action.MAIN"/>
             <category android:ame="android.intent.category.LAUNCHER"/
           </intent-filter>
          </activity
         </application

So when you go to your project overview there are three categories:

1) Project Overview

The project is a broad project overview which contains the idea files, your app files, gradle files and other files which your Android Studio needs to compile them.

2) Package Overview

The second overview is the package these are the packages your app while creating an app.

3) Android Overview

But the most important while developing your Android app is the Android category itself this is where all your programmable files are there and design of these activities.

Now when you go to your app in Android project overview, there will a folder called res folder. And inside this res folder, there are some folders, like drawable, which contains some png files and your main activity or activity file, which is activity_main.xml file. Other files are menu files, and values category.

But right now, the main important design xml file is the activity_main.xml So you can click or you can open this activity_main.xml file when you click on the text, it will open an xml file and this activity_main.xml file is the main xml file, which is responsible for the design of your Android activity.

<RelativeLayout xmls:android="htp://schema
     xmls:tools="http//schemas.android.com/
     android:layout_height="match_parent"and
     android:padddingRight="16dp"
     android:paddingBottom="16dp"tools:conte
     android:id="@+id/">
   <TextView android:text="Hello world"an
        android:layout_height="wrap_content"
<RelativeLayout>

Now go to design and drag and drop these pallete widgets in your activity.There are many widgets like layouts, text fields and other designable tools.For example, we can just drag and drop from this widgets the large text and we can just write anything there just by double clicking. The Android Studio will assist you to align your widgets or tools in your activity.

Now once you added the large text widget in the design view there will be also text view will automatically add to the xml file. We can edit my the file and it can be edited to design view also. You can add more properties to your text view, for example, you can go to the design and you can change these properties from design view also.

There are so many properties. For example, If you want to change the background colour of the text view go to the properties and search for a property called background which is responsible for the background colour of the property and go to the colour choose any colour for text view.

Now this is just the design part of your Android app but the main brain or you can say, main actions are taken in the folder called Java and there is a Java class or Java file called main activity. It contains the class which is responsible for all the main actions of your app.

So for example, you go to your main activity and you add some button here and you click this button. The code for clicking this button and whatever action will be taken while clicking this button will be written here. Therefore the Java class which extends or inherits the action bar activity class.

package com.example.programmingknowledge.thefirstapp;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
amport android.view.MenuItem;

public class MainActivity extends Action Bar Activity{
 @Override
  protected void onCreate (Bundle savedInstancesState)
     super.onCreate(savedInstancesState);
     setContentView(R.layout.activity_main);
}
@Override
pulic boolean onCreateOptionsMenu(Menu menu) {


 

There is one more interesting folder in this app, called manifests that contains the file called AndroidManifest.xml and all the activities of your Android app. Then there can be something like one activity below the second activity below this third activity and so on. So it is the main launcher, of your app.

So for the first time, whenever you launch your application, how will your Android app know that which activity should appear if your Android app can contain many activities and which activity to launch first, this is decided by this xml file. All all the activity mapping will be here in this folder along with other properties of your app. For example, your packages information or other information related to your app will be here. So your app name and styles and other things. So here all the activity listings will be here.

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends ActionBarActivity {
@override
protected void onCreate(Bundle savedInstanceState) {
  super.oncreate(savedinstanceState);
  setContentView(R.layout.activity_main);
}
@Override
publicboolen onCreateOptionMenu(Menu menu) {
//Inflate the menu;this adds iems to the action bar if it s pre
getmenuInflator().inflate(R.menu.menu_main,menu);
return true;

Read Next About Android Activity Lifecycle Overview


Related Articles