ANDROID PROGRAMS DAY 3

Similar documents
TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

Android Programs Day 5

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

Intents. Your first app assignment

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

Basic GUI elements - exercises

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

Data Persistence. Chapter 10

Create Parent Activity and pass its information to Child Activity using Intents.

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

StoppUhr. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start1"


M.A.D Assignment # 1

Our First Android Application

Dynamically Create Admob Banner and Interstitial Ads

Arrays of Buttons. Inside Android

Fragment Example Create the following files and test the application on emulator or device.

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

else if(rb2.ischecked()) {

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Serious Gaming. Technical manual. This document is a collection of the code and installation process

Mobile Software Development for Android - I397

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

Android UI Development

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Fragments. Lecture 11

Android Layout Types

APPENDIX. Application User. MainActivity.java. RegistrationActivity.java

<uses-permission android:name="android.permission.internet"/>

Accelerating Information Technology Innovation

05. RecyclerView and Styles

Text Properties Data Validation Styles/Themes Material Design

// MainActivity.java ; Noah Spenser; Senior Design; Diabetic Breathalyzer

South Africa

Android Application Development. By : Shibaji Debnath

android-espresso #androidespresso

UI (User Interface) overview Supporting Multiple Screens Touch events and listeners

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop


Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Android Tutorial: Part 3

Introduction to Android Development

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android.

Embedded Systems Programming - PA8001

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

Vienos veiklos būsena. Theory

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

android:layout_margintop="5dp" > <EditText android:layout_width="210dp"

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

LAB MANUAL SITTTR KALAMASSERY SMART DEVICE PROGRAMMING LAB. SITTTR Smart Device Programming Manual Page 1

Software Practice 3 Before we start Today s lecture Today s Task Team organization

1. Simple List. 1.1 Simple List using simple_list_item_1

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

Android/Java Lightning Tutorial JULY 30, 2018

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

INTENTS android.content.intent

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

使用 TensorFlow 設計矩陣乘法計算並轉移執行在 Android 上 建國科技大學資管系 饒瑞佶 2017/8

Android - Widgets Tutorial

Starting Another Activity Preferences


Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Produced by. Mobile Application Development. Eamonn de Leastar

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

Tabel mysql. Kode di PHP. Config.php. Service.php

Android Workshop: Model View Controller ( MVC):

Manifest.xml. Activity.java

EMBEDDED SYSTEMS PROGRAMMING Android Services

Android HelloWorld - Example. Tushar B. Kute,

COMP61242: Task /04/18

API Guide for Gesture Recognition Engine. Version 2.0

By Ryan Hodson. Foreword by Daniel Jebaraj

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

ELET4133: Embedded Systems. Topic 15 Sensors

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

Mobile Computing Practice # 2c Android Applications - Interface

Kotlin for Android developers

Time Picker trong Android

APPENDIX. Application Store Admin. build.gradle. app/build.gradle

Database Development In Android Applications

<uses-permission android:name="android.permission.internet" />

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

TPCT s College of Engineering, Osmanabad. Laboratory Manual SDL-II. Mobile Application Development (Android) For. Third Year Students (CSE)

ANDROID USER INTERFACE

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

POCKET STUDY. Divyam Kumar Mishra, Mrinmoy Kumar Das Saurav Singh, Prince Kumar

APPENDIX CODE TO STORE THE BUTTON MENU AND MOVE THE PAGE

Debojyoti Jana (Roll ) Rajrupa Ghosh (Roll ) Sreya Sengupta (Roll )

Transcription:

ANDROID PROGRAMS DAY 3 //Android project to navigate from first page to second page using Intent Step 1: Create a new project Step 2: Enter necessary details while creating project. Step 3: Drag and drop a button in activity_main.xml file. Step 4: Add android:onclick= visitsecondpage in activity_main.xml file. Step 5: Right click on the folder which consists of MainActivity.java file, add new Activity class. New Activity Empty Activity

Step 6: Give appropriate Activity name for the new class. Step 7: Open activity_second.xml file and add a TextView for a Welcome message. Step 8: Open MainActivity.java class and in the visitsecondpage function, create Intent object. Intent obj = new Intent(this, SecondActivity.class); startactivity(obj); Step 9: Run the Application and test the working. //activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.pramod.vc_inentsimple.mainactivity"> <TextView android:text="hello World!" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" app:layout_constraintvertical_bias="0.228" /> <Button android:id="@+id/button" android:text="button" android:onclick="visitsecondpage"

app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" tools:layout_constrainttop_creator="1" tools:layout_constraintbottom_creator="1" app:layout_constraintbottom_tobottomof="parent" app:layout_constrainttop_totopof="parent" /> </android.support.constraint.constraintlayout> //MainActivity.java import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; public class MainActivity extends AppCompatActivity @Override protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); public void visitsecondpage (View view) Intent obj = new Intent(this, SecondActivity.class); startactivity(obj);

//activity_second.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.pramod.vc_inentsimple.secondactivity"> <TextView android:id="@+id/textview" android:text="welcome to Second Page" android:textappearance="@android:style/textappearance.large" tools:layout_constrainttop_creator="1" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" android:layout_margintop="117dp" app:layout_constrainttop_totopof="parent" /> </android.support.constraint.constraintlayout> // SecondActivity.java import android.support.v7.app.appcompatactivity; import android.os.bundle; public class SecondActivity extends AppCompatActivity @Override protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_second);

//Android project to pass data from first page to second page using Intent object. Step 1: Create a new project Step 2: Enter necessary details while creating project. Step 3: Drag and drop a EditText and a button in activity_main.xml file. Step 4: Add android:onclick= visitsecondpage in activity_main.xml file. Step 5: Add android:hint= Name in the activity_main.xml file. Step 6: Right click on the folder which consists of MainActivity.java file, add new Activity class. New Activity Empty Activity Step 7: Give appropriate Activity name for the new class.

Step 8: Open activity_second.xml file and add a TextView for a Welcome message. Step 9: Create an EditText object in MainActivity.java file. Step 10: In the visitsecondpage function, extract string entered in the EditText widget and store it in a string object. EditText txt = (EditText)findViewById(R.id.editText); String str = txt.gettext().tostring(); Step 11: Create Intent object and pass the string value to second page using putextra() function. Intent obj = new Intent(this, SecondActivity.class); obj.putextra("name", str); startactivity(obj); Step 12: Open SecondActivity.java file extract the data passed from MainActivity using Bundle object. Store the value in a string object. Bundle obj = getintent().getextras();

String str1 = obj.getstring("name"); Step 13: Set the welcome message in a TextView using settext() function in SecondActivity.java file TextView tv = (TextView)findViewById(R.id.textView); tv.settext("welcome to Second Page " + str1); Step 14: Run the Application and test the working. //activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.pramod.vc_intentdatapassing.mainactivity">

<Button android:id="@+id/button" android:text="button" android:onclick="visitsecondpage" tools:layout_constrainttop_creator="1" android:layout_marginend="61dp" app:layout_constraintright_torightof="@+id/edittext" android:layout_margintop="95dp" app:layout_constrainttop_tobottomof="@+id/edittext" /> <EditText android:id="@+id/edittext" android:ems="10" android:inputtype="textpersonname" android:hint="name" tools:layout_constrainttop_creator="1" android:layout_marginstart="67dp" android:layout_margintop="71dp" app:layout_constraintleft_toleftof="parent" app:layout_constrainttop_totopof="parent" /> </android.support.constraint.constraintlayout> //MainActivity.java import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; public class MainActivity extends AppCompatActivity EditText txt; @Override protected void oncreate(bundle savedinstancestate)

super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); public void visitsecondpage (View view) txt = (EditText)findViewById(R.id.editText); String str = txt.gettext().tostring(); Intent obj = new Intent(this, SecondActivity.class); obj.putextra("name", str); startactivity(obj); //activity_second.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.pramod.vc_intentdatapassing.secondactivity" > <TextView android:id="@+id/textview" android:text="welcome to Second Page" android:textappearance="@android:style/textappearance.large" tools:layout_constrainttop_creator="1" app:layout_constraintleft_toleftof="parent"

app:layout_constraintright_torightof="parent" android:layout_margintop="117dp" app:layout_constrainttop_totopof="parent" /> </android.support.constraint.constraintlayout> // SecondActivity.java import android.support.v7.app.appcompatactivity; import android.os.bundle; public class SecondActivity extends AppCompatActivity @Override protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_second); Bundle obj = getintent().getextras(); String str1 = obj.getstring("name"); TextView tv = (TextView)findViewById(R.id.textView); tv.settext("welcome to Second Page " + str1); //Android project to Create a Registration Page and use Intent to send data to next page Step 1: Create a new project Step 2: Enter necessary details while creating project. Step 3: Add necessary widgets in activity_main.xml file. Step 4: Add android:onclick= visitsecondpage in activity_main.xml file.

Step 5: Right click on the folder which consists of MainActivity.java file, add new Activity class. New Activity Empty Activity //activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ibmsap.test_registration_new.mainactivity"> <TextView android:text="welcome to registration page" android:textappearance="@android:style/textappearance.large" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" app:layout_constraintvertical_bias="0.031" android:id="@+id/textview" /> <EditText android:id="@+id/edittext" android:layout_marginend="36dp" android:layout_margintop="19dp" android:ems="10" android:hint="enter Your Name" android:inputtype="textpersonname" app:layout_constraintright_torightof="@+id/textview" app:layout_constrainttop_tobottomof="@+id/textview" tools:layout_constrainttop_creator="1" />

<EditText android:id="@+id/edittext2" android:layout_margintop="23dp" android:ems="10" android:hint="enter Your USN" android:inputtype="textpersonname" app:layout_constraintleft_toleftof="@+id/edittext" app:layout_constraintright_torightof="@+id/edittext" app:layout_constrainttop_tobottomof="@+id/edittext" tools:layout_constrainttop_creator="1" /> <EditText android:id="@+id/edittext3" android:layout_marginend="1dp" android:layout_margintop="14dp" android:ems="10" android:hint="enter Your EMail ID" android:inputtype="textemailaddress" app:layout_constraintright_torightof="@+id/edittext2" app:layout_constrainttop_tobottomof="@+id/edittext2" tools:layout_constrainttop_creator="1" /> <CheckBox android:id="@+id/checkbox" android:layout_marginstart="16dp" android:layout_margintop="23dp" android:text="python" app:layout_constraintleft_toleftof="parent" app:layout_constrainttop_tobottomof="@+id/edittext3" tools:layout_constrainttop_creator="1" /> <CheckBox android:id="@+id/checkbox2"

android:text="c++" tools:layout_constrainttop_creator="1" android:layout_marginstart="50dp" android:layout_margintop="22dp" app:layout_constrainttop_tobottomof="@+id/edittext3" app:layout_constraintleft_toleftof="@+id/edittext3" /> <CheckBox android:id="@+id/checkbox3" android:layout_marginend="49dp" android:layout_margintop="22dp" android:text="java" app:layout_constraintright_torightof="parent" app:layout_constrainttop_tobottomof="@+id/edittext3" tools:layout_constrainttop_creator="1" /> <CheckBox android:id="@+id/checkbox4" android:layout_marginstart="16dp" android:layout_margintop="13dp" android:text="android" app:layout_constraintleft_toleftof="parent" app:layout_constrainttop_tobottomof="@+id/checkbox" tools:layout_constrainttop_creator="1" /> <RadioGroup android:layout_width="0dp" android:id="@+id/radiogroup" app:layout_constraintright_toleftof="@+id/checkbox2" tools:layout_constrainttop_creator="1" android:layout_marginstart="8dp" android:layout_marginend="6dp"

android:layout_margintop="20dp" app:layout_constrainttop_tobottomof="@+id/checkbox4" app:layout_constraintleft_toleftof="parent"> <RadioButton android:id="@+id/radiobutton2" android:layout_weight="1" android:text="second year" /> <RadioButton android:id="@+id/radiobutton3" android:layout_weight="1" android:text="third Year" /> <RadioButton android:id="@+id/radiobutton" android:layout_weight="1" android:text="fourth Year" tools:layout_editor_absolutex="16dp" tools:layout_editor_absolutey="317dp" /> </RadioGroup> <Button android:id="@+id/button" android:layout_marginbottom="30dp" android:layout_marginstart="25dp" android:onclick="registerdetails" android:text="submit" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_torightof="@+id/radiogroup" tools:layout_constraintbottom_creator="1" /> </android.support.constraint.constraintlayout>

//MainActivity.java import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.checkbox; import android.widget.edittext; import android.widget.radiobutton; import android.widget.radiogroup; import android.widget.toast; public class MainActivity extends AppCompatActivity EditText name, usn, email; CheckBox chk1, chk2, chk3, chk4; RadioGroup rgp; RadioButton rb1; @Override protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); name = (EditText)findViewById(R.id.editText); usn = (EditText)findViewById(R.id.editText2); email = (EditText)findViewById(R.id.editText3); chk1 = (CheckBox)findViewById(R.id.checkBox); chk2 = (CheckBox)findViewById(R.id.checkBox2); chk3 = (CheckBox)findViewById(R.id.checkBox3); chk4 = (CheckBox)findViewById(R.id.checkBox4); rgp = (RadioGroup)findViewById(R.id.radioGroup); //rb1 = (RadioButton)findViewById(R.id.radioButton2); //rb2 = (RadioButton)findViewById(R.id.radioButton3); //rb3 = (RadioButton)findViewById(R.id.radioButton); public void registerdetails(view view) String str1, str2, str3; String courses = ""; str1 = name.gettext().tostring();

str2 = usn.gettext().tostring(); str3 = email.gettext().tostring(); if(str1.isempty() str2.isempty() str3.isempty() ) Toast.makeText(getApplicationContext(), "Please Enter Your Details", Toast.LENGTH_LONG).show(); else if(chk1.ischecked()) courses = courses + chk1.gettext().tostring(); //courses = courses + "Python"; if(chk2.ischecked()) courses = courses + chk2.gettext().tostring(); if(chk3.ischecked()) courses = courses + chk3.gettext().tostring(); if(chk4.ischecked()) courses = courses + chk4.gettext().tostring(); int id = rgp.getcheckedradiobuttonid(); rb1 = (RadioButton)findViewById(id); String year = rb1.gettext().tostring(); Intent obj = new Intent(getApplicationContext(), Main2Activity.class); obj.putextra("name", str1); obj.putextra("usn", str2); obj.putextra("email", str3); obj.putextra("courses", courses); obj.putextra("year", year); startactivity(obj); //activity_main2.xml <?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.ibmsap.test_registration_new.main2activity"> </android.support.constraint.constraintlayout> //Main2Activity.java import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.widget.toast; public class Main2Activity extends AppCompatActivity @Override protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main2); Bundle obj = getintent().getextras(); String name = obj.getstring("name"); String usn = obj.getstring("usn"); String email = obj.getstring("email"); String courses = obj.getstring("courses"); String year = obj.getstring("year"); String str = "Name : " + name + "\nusn : " + usn + "\nemail ID : " + email + "\ncourses : " + courses + "\nyear : " + year; Toast.makeText(getApplicationContext(), str, Toast.LENGTH_LONG).show();