Intents. Your first app assignment

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

Basic GUI elements - exercises

Arrays of Buttons. Inside Android

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

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

ANDROID PROGRAMS DAY 3

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

Android Programs Day 5

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

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

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

Dynamically Create Admob Banner and Interstitial Ads

M.A.D Assignment # 1

android-espresso #androidespresso

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

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

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

Vienos veiklos būsena. Theory

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


Fragments. Lecture 11

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

PROGRAMMING APPLICATIONS DECLARATIVE GUIS

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

Our First Android Application

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

05. RecyclerView and Styles

Android CardView Tutorial

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

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

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

Android Application Development. By : Shibaji Debnath

Creating a Custom ListView

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


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

ELET4133: Embedded Systems. Topic 15 Sensors

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

Lecture 14. Android Application Development

Android UI Development

Starting Another Activity Preferences

Manifest.xml. Activity.java

Practical 1.ListView example

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

Android Workshop: Model View Controller ( MVC):

Notification mechanism

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

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

API Guide for Gesture Recognition Engine. Version 2.0

Android/Java Lightning Tutorial JULY 30, 2018

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

ANDROID USER INTERFACE

Data Persistence. Chapter 10

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

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

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)

Text Properties Data Validation Styles/Themes Material Design

Android HelloWorld - Example. Tushar B. Kute,

LAMPIRAN PROGRAM. public class Listdata_adiktif extends ArrayAdapter<ModelData_adiktif> {

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

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27


Mobile Software Development for Android - I397

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

Fragments. Lecture 10

Android Tutorial: Part 3

Simple Currency Converter

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

API Guide for Gesture Recognition Engine. Version 1.1

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

Open Lecture Mobile Programming. Intro to Material Design

Chapter 5 Flashing Neon FrameLayout

App Development for Smart Devices. Lec #18: Advanced Topics

Action Bar. (c) 2010 Haim Michael. All Rights Reserv ed.

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

Programmation Mobile Android Master CCI

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

Adapter.

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

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

SMART VEHICLE TRACKING APPLICATION

else if(rb2.ischecked()) {

SMAATSDK. NFC MODULE ON ANDROID REQUIREMENTS AND DOCUMENTATION RELEASE v1.0

Kotlin for Android developers

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

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

Android - JSON Parser Tutorial

Database Development In Android Applications

EMBEDDED SYSTEMS PROGRAMMING Android Services

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

Learn about Android Content Providers and SQLite

BSCS 514- Computer Graphics. Course Supervisor : Dr. Humera Tariq Hands on Lab Sessions: Mr. Faraz Naqvi

Embedded Systems Programming - PA8001

Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento

Accelerating Information Technology Innovation

Topics of Discussion

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

Transcription:

Intents Your first app assignment

We will make this. Decidedly lackluster.

Java Code Java Code XML XML Preview

XML Java Code Java Code XML

Buttons that work <Button android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="begin" /> Id needed only if the View changes OR for relative layout. android:layout_gravity="center_horizontal" android:onclick="tosecond" Method in Java file associated with this button.

Java file associated with last button package ca.gorskicompsci.www.storycubes; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; Libraries public class MainActivity extends AppCompatActivity { @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); public void tosecond(view view){ For the button s onclick Inflation

Making a new screen Make a new activity and it will follow.

To make a new screen, click on the app folder (the first one). Select new > Activity > Empty Activity.

Choose the name you want. Click finish.

Automatically generated Look at the files in the Project. An activity and an XML have been generated.

Repeat until you have all of your screens. Then, build the basic XML for each.

To Switch Screens public void tosecond(view view){ Intent i = new Intent(this, InstructionsActivity.class); startactivity(i); The class name (in Java) of the XML/java pair you want.

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="16dp" android:paddingright="16dp" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="welcome to Story Cubes" android:textsize="30dp" android:paddingtop="150dp" android:paddingbottom="100dp" /> <Button android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="begin" android:layout_gravity="center_horizontal" android:onclick="tosecond"/> </LinearLayout> package ca.gorskicompsci.www.storycubes; Screen 1 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 tosecond(view view){ Intent i = new Intent(this, InstructionsActivity.class); startactivity(i);

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="16dp" android:paddingright="16dp" android:orientation="vertical" > Screen 2 <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="great Instructions" android:layout_gravity="center_horizontal" android:textsize="30dp" android:paddingtop="150dp" android:paddingbottom="100dp" /> <Button android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="play Great Game" android:layout_gravity="center_horizontal" android:onclick="togame"/> </LinearLayout> package ca.gorskicompsci.www.storycubes; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; public class InstructionsActivity extends AppCompatActivity { @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_instructions); public void togame(view view){ Intent i = new Intent(this, Game.class); startactivity(i);

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="16dp" android:paddingright="16dp" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="click to roll the story dice." android:layout_gravity="center_horizontal" android:paddingtop="100dp" android:paddingbottom="50dp" android:textsize="25dp"/> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:src="@drawable/sc1" android:onclick="roll" android:id="@+id/dice" /> <Button android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="instructions" android:layout_gravity="center_horizontal" android:onclick="backtoinstructions"/> </LinearLayout> Screen 3 package ca.gorskicompsci.www.storycubes; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.imagebutton; public class Game extends AppCompatActivity { @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_game); public void backtoinstructions(view view){ Intent i = new Intent(this, InstructionsActivity.class); startactivity(i); public void roll(view view){ ImageButton ib = (ImageButton) findviewbyid(r.id.dice); int num = (int) (Math.random()*6); if(num==1) ib.setimageresource(r.drawable.sc1); else if(num==2) ib.setimageresource(r.drawable.sc2); else if(num==3) ib.setimageresource(r.drawable.sc3); else if(num==4) ib.setimageresource(r.drawable.sc4); else if(num==5) ib.setimageresource(r.drawable.sc5); else ib.setimageresource(r.drawable.sc6);

public void roll(view view){ ImageButton ib = (ImageButton) findviewbyid(r.id.dice); int num = (int) (Math.random()*6); if(num==1) ib.setimageresource(r.drawable.sc1); else if(num==2) ib.setimageresource(r.drawable.sc2); else if(num==3) ib.setimageresource(r.drawable.sc3); else if(num==4) ib.setimageresource(r.drawable.sc4); else if(num==5) ib.setimageresource(r.drawable.sc5); else ib.setimageresource(r.drawable.sc6); To Roll the Dice