Tuesday, November 29, 2016

Hello World

It will be a simple program in which we will see how to output a sample text, say, Hello World in an android virtual device.


 Steps to create a hello world project on android studio.
  1. Crate a project in android studio.
  2.  Update your main_activity.xml
    <?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:id="@+id/activity_main"
        android:layout_width="match_parent"
        android:gravity="center"
        android:layout_height="match_parent"
        tools:context="com.pankaj.helloworld.MainActivity">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!" />
    </RelativeLayout>
    
      
  3. No change in your MainActivity.JAVA

    package com.pankaj.helloworld;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    }
    
    

     
  4. Now all the development has completed for hello world application, Please run the project.

  5. Now you will see result screen-

     
  6.  Good bye, Thanks to read this blog.




No comments:

Post a Comment