Saturday, 30 January 2016

My first android app or How to create android app or how to create my first android

Hi friends you will to start button of your computer and search eclipse and open it for start android programming with java. After open eclipse ADT goto left top on File-> New -> Project and select Android New Application.

Hello Android Wizard


Next, and follow the instructions provided and keep all other entries as default till the final step. Once your project is created successfully, you will have following

Hello Android Project

and you will change here as you want in activity_main.xml file is in project file in res-> layout folder and in MainActivity.java  in project folder src-> packagename folder-> .java file

like as

Android Directory Structure

and following details about these folder

src
This contains the .java source files for your project. By default, it includes an MainActivity.java source file having an activity class that runs when your app is launched using the app icon.

gen
This contains the .R file, a compiler-generated file that references all the resources found in your project. You should not modify this file.

bin
This folder contains the Android package files .apk built by the ADT during the build process and everything else needed to run an Android application.

res/drawable-hdpi
This is a directory for drawable objects that are designed for high-density screens.

res/layout
This is a directory for files that define your app's user interface.

res/values
This is a directory for other various XML files that contain a collection of resources, such as strings and colours definitions.

AndroidManifest.xml
This is the manifest file which describes the fundamental characteristics of the app and defines each of its components.

package com.akharipoint.helloworld;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;

public class MainActivity extends Activity {

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main); 
//layout file in res->layout folder for design or componet 
//of UI of screen which is interact with user.
 }
 //for menu like home, settings and etc. is exist in res->values-> .xml  
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
   }
}

 activity_main.xml


res->layout-> .xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >
   
   <TextView android:id="@+id/hello_txt"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:text="@string/hello_world"/>
      
</RelativeLayout>

 strings.xml

res->values->.xml

<resources>
   <string name="app_name">HelloWorld</string>
   <string name="hello_world">Hello world!</string>
   <string name="menu_settings">Settings</string>
   <string name="title_activity_main">MainActivity</string>
</resources>
 
after this successfully you will run this app right click on the project 
 and select option run as android application 
 you will run this app from top menu bar of eclipse run option and run successfully.

Happy to Code ....

No comments:

Post a Comment