Friday, March 17, 2017

Create your First Android Application 'Hello World'

1. Create New Android Application.


           Select File --> New--> New Project




2. Configure your project.


      Here you can configure your project name, project location, then click Next button




3.  Set Minimum SDK    






4. Select Activity



5 Modify Layout File


Your layout file should be like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingBottom="@dimen/activity_vertical_margin"    
                android:paddingLeft="@dimen/activity_horizontal_margin"    
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:paddingTop="@dimen/activity_vertical_margin"
                tools:context="com.donix.helloworldapp.MainActivity">
    <TextView  android:layout_width="wrap_content" 
               android:layout_height="wrap_content"
               android:text="Hello World!" />
</RelativeLayout>





6. Modify Activity Java File.


Your java file should be like this:
public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

// Mention your layout file where textview is defined 
        setContentView(R.layout.activity_main);
        Toast.makeText(this,"Hello World",Toast.LENGTH_LONG).show();

    }

}

7. Running Your Application.



To Run your Application,First start AVD/Emulator or Connect your phone to pc, then Click on Run 
button