0% found this document useful (0 votes)
46 views

Introduction To Android Development - Part1

The document discusses setting up an Android application project in Android Studio and creating a simple "Hello World" app. It includes steps to: 1) Open a blank template project named "Hello_world" with a minimum API level of 19 and Java language. 2) View the project structure which includes the mainactivity.java file and app/sources folders. 3) Add an icon to the app and configure the manifest file. 4) Create a simple app by dragging a text field and button onto the view and setting their properties. The document then provides an overview of variables, operators, control flows and arrays in Java code for Android applications.

Uploaded by

hareesh.cse21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Introduction To Android Development - Part1

The document discusses setting up an Android application project in Android Studio and creating a simple "Hello World" app. It includes steps to: 1) Open a blank template project named "Hello_world" with a minimum API level of 19 and Java language. 2) View the project structure which includes the mainactivity.java file and app/sources folders. 3) Add an icon to the app and configure the manifest file. 4) Create a simple app by dragging a text field and button onto the view and setting their properties. The document then provides an overview of variables, operators, control flows and arrays in Java code for Android applications.

Uploaded by

hareesh.cse21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Application setup

➔ open a Blank template


↳ Name: Hello_world
↳ language: Java
↳ Minimum API level: API_ 19
➔ Build: progress
➔ Project:➔ Project(structure of like an your system) for
mainactivity.java ➔ app ➔ sources ➔ main ➔ java
↳ the project view is exact hierarchy.
➔ Android view:
↳ App ➔ java ➔ package ➔ main
↳ res ➔ mitmap ➔ icon for android app
↳ manifest file ➔ manifest folder. (features)
➔ // Todo
➔ View ➔ Tool window ➔ profiler.
➔ Pixel 29

Simple app

• Insert the text field through


Text field ➔ Plain Text ➔ Drag it to the field
• set the position
• similarly add Button
• Give id and text(give as hint)
Task

Create a app that will show your first name, Last Name, Email after typing these information and
click on the button in the screen (As in the figure shown below).
Java code:
Variables and Arithmetic operations
➔ for java We need IDE
➔ Video: Android Studio doesn’t support plain java code any more what to do Now!
➔ Another IDE: Eclips, Intellij IDEA install it
➔ Open Intellij IDEA
↳ Create new process
↳ select java path to JDK
↳ Uncheck Project template Game
↳ Project Name: Hello world Right click res → new package →
org.mycode.helloworld
↳ Right click package Java Class Hellow
↳ pvsm : Public Static void main
↳ sout :System.out.print
↳ Right click curly brace - Run
↳ //Todo

Variable
➔ int, long, double, float
➔ Character: chat(‘\u :for Unicode), string: It is class in java others are data type
➔ Boolean

Operators
➔ +, -, *, /, %
➔ + can also use to add strings(Concatenate).

Relational Operator and Loop


➔ A++, a--
➔ >, <, ==, !=, >=, <= } comparison op
➔ ||, &&

◦ if(condition) {
Statements;
}
◦ if( condition){
Statement Block 1;
}
else{
Statement Block2;
}
◦ if-else if
➔ Switch (variable) {
Case1:Statement1; break;
Case2:Statement2; break;
………………………….
………………………….
default:default Statement; break;
}
Loops

◦ for (initialization; condition, updation){


Statement block:
}
◦ while(condition) {
Statement block;
updation;
}
◦ Continue: go to next Iteration doesn’t run remaining current iteration(drop a iteration)
◦ do{
Statement Block;
Updation;
}while (condition)
➔ Scanner scanner = new Scanner(System.in);
➔ int ans = Scanner.nextInt(); //read a integer from user input
➔ String name = Scanner next(); -string
➔ Random random= new Random();
➔ int num = random.nextInt();
inside brace give Domain. eg: bound: 20(this will give a random number between 0 –
20)

Task Game

• Show a welcome message


• concept, generate a random number and ask user to guess number, continue until you get the
number
• asking - after 5 time of guessing show Game over
• Ask user name and say hello
• Ask if we should Start
• After user’s positive response - generate random number and ask for user guess
• If right Guess show congratulation message and Quit the Game
• It not ask again
• As a hint, beside the first time, every time that you are asking for a number tell the user to
guess higher on lower
• if user fail 5 times show game over and quit
Simple Arrays

➔ Syntax 1:
Sting [] student = new String[]; //inside the square bracket size.
➔ Student [1] = "meisam" // inserting value
➔ String start from 0
➔ Syntax 2:
String[] employees = {"meisam" ,"Tom","Sarah"};
➔ int[] number = {1,2,3};
➔ numbers length – give the size of string (string length)
➔ for Comparing string we use
finddata.equals(data[i])
➔ Program to find number of a person from datas.

You might also like