Basic GUI elements - exercises

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

Intents. Your first app assignment

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

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

ANDROID PROGRAMS DAY 3

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

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

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


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

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

Data Persistence. Chapter 10

Manifest.xml. Activity.java

Arrays of Buttons. Inside Android

Android Programs Day 5

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

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

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

else if(rb2.ischecked()) {

M.A.D Assignment # 1

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

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

Android/Java Lightning Tutorial JULY 30, 2018

android-espresso #androidespresso

Interaction with Android

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

Vienos veiklos būsena. Theory

Simple Currency Converter

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

Lecture 14. Android Application Development

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Database Development In Android Applications

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

Android Beginners Workshop

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

Mobile Software Development for Android - I397

Android UI Development

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

By The Name of Allah. The Islamic University of Gaza Faculty of Engineering Computer Department Final Exam. Mobile Computing



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

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

Android Workshop: Model View Controller ( MVC):

Android HelloWorld - Example. Tushar B. Kute,

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

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

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

Our First Android Application

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

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

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

Graphical User Interfaces

COMP4521 EMBEDDED SYSTEMS SOFTWARE

PROGRAMMING APPLICATIONS DECLARATIVE GUIS

Practical 1.ListView example

Interface ใน View class ประกอบด วย

COMP61242: Task /04/18

Embedded Systems Programming - PA8001

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

Press project on the left toolbar if it doesn t show an overview of the app yet.

Notification mechanism

ANDROID USER INTERFACE

Android Tutorial: Part 3

Text Properties Data Validation Styles/Themes Material Design

LifeStreet Media Android Publisher SDK Integration Guide

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

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

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

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

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

Adapter.

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

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

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

ELET4133: Embedded Systems. Topic 15 Sensors

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

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

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

Android - JSON Parser Tutorial

Chapter 5 Flashing Neon FrameLayout

Computer Science E-76 Building Mobile Applications

APPENDIX CODE TO STORE THE BUTTON MENU AND MOVE THE PAGE

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

Android Layout Types

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

Android CardView Tutorial

INTENTS android.content.intent

Learn about Android Content Providers and SQLite

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

Dynamically Create Admob Banner and Interstitial Ads

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

Android Application Development. By : Shibaji Debnath

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

Meniu. Create a project:

Solving an Android Threading Problem

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

Transcription:

Basic GUI elements - exercises

https://developer.android.com/studio/index.html

LIVE DEMO

Please create a simple application, which will be used to calculate the area of basic geometric figures.

To add images to the drawable forlder, right click on it, and select the Show in Explorer option. Copy images to the opened drawable folder.

<?xml version="1.0" encoding="utf-8"?> <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <TableRow> <ImageView android:id="@+id/img" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/square" /> <TextView android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="square area" android:layout_marginleft="20dp" android:layout_margintop="5dp" android:textsize="20dp" /> </TableRow> </TableLayout>

Create a new activity by chosing the right option from the context menu.

Name the new activity and click finish

package pl.tomaszx.geometry; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.textview; public class MainActivity extends AppCompatActivity { TextView t1; @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } } t1 = (TextView)findViewById(R.id.textView1); View.OnClickListener listener = new View.OnClickListener() { @Override public void onclick(view v) { Intent i = new Intent(getApplicationContext(), SquareActivity.class); startactivity(i); } }; t1.setonclicklistener(listener);

Add some components (widgets) to the Square Activity to recreate the view shown on the left. Usefull ones are: TextView EditText Button

package pl.tomaszx.geometry; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class SquareActivity extends AppCompatActivity { Button calculate; TextView result; EditText side; @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_square); calculate = (Button) findviewbyid(r.id.button1); side = (EditText) findviewbyid(r.id.edittext1); result = (TextView) findviewbyid(r.id.textview1); } } calculate.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view v) { result.settext((double.parsedouble(side.gettext().tostring()) * Double.parseDouble(side.getText().toString())) + ""); } });

Write the following applications using the basic GUI elements (Button, TextView): To simulate a flashlight (by changing the background color of the activity into one of 4 colors). To convert the temperature between Celsius and Kelvin and Fahrenheit To calculate average fuel combustion per 100 km and its cost.

Remember to add: implements OnClickListener

Log hierarchy: Log.v(String, String) - verbose Log.d(String, String) - debug Log.i(String, String) - information Log.w(String, String) - warning Log.e(String, String) - error

Write the following applications: "Guess my number" game. The program draws a number from the range of 2000 to 2000 and the user's task is to guess it (based on "too much", "too little"). The program also displays the number of attempts. Program to calculate the roots of a square equation. Try to secure your applications using: http://developer.android.com/reference/android/text/t extutils.html (isempty method) Integer.parseInt or other standard java methods

Write an application that calculates the BMI. Use the following formula: BMI = weight height 2 [ kg m 2] For example, for 80 kg weight and 1.76 m height the BMI is: BMI = 80 1,76 2 = 80 3,0976 = 25,82 After clicking on a "Calculate" button, display the result to the user.

Write a simple calculator that adds two numbers. Display the result in 3 couting systems: Decimal Binary Hexadecimal