Tampilkan postingan dengan label application. Tampilkan semua postingan
Tampilkan postingan dengan label application. Tampilkan semua postingan

Sabtu, 23 April 2016

As a Beginner You need to know the execution flow of your android application. to understand the basic execution flow of android  we are  considering the hello world example.

When you create the android project in eclipse lots of folder are created such as "src" ,"gen" , "Android 1.5"  , "assets" and "res" folder.
To understand android flow we are starting with the "res" folder. In "res" folder there is a file called "AndroidManifest.xml".
These below is the content of AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest
      package="com.example"
      android_versionCode="1"
      android_versionName="1.0">
    <uses-sdk android_minSdkVersion="3" />
    <application android_icon="@drawable/icon" android_label="@string/app_name">
        <activity android_name=".HelloWorldDemo"
                  android_label="@string/app_name">
            <intent-filter>
                <action android_name="android.intent.action.MAIN" />
                <category android_name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
      
    </application>
</manifest>

In the Above Xml code we have an activity called "HelloWordDemo" listed in activity tag this activity will be launched first. if you have multiple activity in your android application you must have to register all your activity in AndroidManifest.xml file.
you can specify your child activity by just <activity android_name=".xyz"></activity> adding as many tag as many activity you have in your android application. Make sure you specify "." (dot) before each activity.
Activity name ".HelloWorldDemo" will call HelloWorldDemo.java file.
package com.example;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorldDemo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
When HelloWorldDemo Activity is created by default onCreate method will be executed. inside onCreate Method we have an setContentView which execute the android application design file whose name is main.xml  because we have R.layout.main as an argument.
In Brief  AndroidManifest.xml file execute the Launcher Activity class and from the launcher activity onCreate method will execute the Design View file by using setContentView method.


Android Apk
Read More..

Jumat, 04 Maret 2016

Create “Hello World” application. That will display “Hello World” in the middle of the screen in the
red color with white background.

Click Below Link to download Hello World Application. Although i recommend you to read below steps to understand how to develop Android Application

Download Hello World Android Application

Create Hello World Application follow these basic steps. Below Steps are after the configuration of SDK Manager and eclipse.
STEP 1
Start Eclipse and Choose Workspace where you want to save your project

STEP 2 
Click on the file menu -> Select New -> Choose Android Project
 New Android Project Dialog will displayed and fill the required information and click on the finish button



Here In Above Dialog box Create Activity is the name of class you want to specify for your default Activity which will be loaded first when Hello World Example will be executed.


STEP 3
From the Project explorer click on the HelloWorld  -> res - > layout. it will show the main.xml inside layout folder. double click on the main.xml. By clicking on main.xml it will show something like.

Drag the Text View Control from  left panel to black box. and click on the main.xml tab show bottom left near Graphical Layout. now the main coding or designing part starts.

Main.xml file content for Hello World Example

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android_orientation="vertical"
    android_layout_width="fill_parent"
    android_layout_height="fill_parent"
    android_background="#999">
 
    <TextView
        android_layout_height="fill_parent"
        android_text="Hello World"
        android_textColor="#900"
        android_id="@+id/textView1"
        android_layout_width="fill_parent"
        android_gravity="center_vertical|center_horizontal">
    </TextView>


</LinearLayout>

STEP 4
When you drag  control to Graphical Layout  in background it will generate the xml code appropriate to those control. In our Example we have dragged TextView Control so here we can see the TextView tag. and LinearLayout tag. LinearLayout is the default layout which hold the View Control as well other Layout if you want to specify for your design.



TextView

We have android:text = "Hello World"  attribute which show the text to screen. here we have specified "Hello World".

android:textColor="#900"  you can specify the Text Color in RGB format RED , GREEN and BLUE.
android:layout_height="fill_parent"  TextView Control Height would be equal to the height of its parent control. in our example parent is LinearLayout. same thing would be applied to android:layout_width

android:gravity="center_vertical|center_horizontal"   you can specify the alignment of the control

LinearLayout

android:background="#999"   We have Specified the Background color of LinearLayout to White Color

STEP 5
Click on the run  to execute our Hello World Application Example.


Download Hello World Android Application


Android Apk
Read More..