CS323 Android Model-View-Controller Architecture

Slides:



Advertisements
Similar presentations
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Advertisements

Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.
1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.
Android - Broadcast Receivers
Programming with Android: Layouts, Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Recap of Part 1 Terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel? Activities Views / ViewGroups Intents Services.
COMP 365 Android Development.  Developing for Android  XML for user interface formatting and other scripting  Java for programming.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Cosc 5/4730 Support design library. Support Design library Adds (API 9+) back support to a number of 5.0 lollipop widgets and material design pieces –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Lab7 – Appendix.
Mobile Computing CSE 40814/60814 Spring 2017.
Introduction to android
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Adapting to Display Orientation
Mobile Software Development for Android - I397
Android Dr. Vaishali D. Khairnar IT Department
Android Widgets 1 7 August 2018
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
android architecture components with mvvm
Android 7: Assignment 2, Part 1, One Button Recursion and Debugging
Android 7: One Button Recursion and Debugging
Android 10: The Silly String App
Android Introduction Camera.
Android 10: The Silly String App
Android SDK & App Development
Android App Computations
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Programming Lecture 6
Android Layout Basics Topics
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Sensor Programming
Building User Interfaces Basic Applications
Android Topics UI Thread and Limited processing resources
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Android Developer Fundamentals V2
Activities and Intents
Android Developer Fundamentals V2 Lesson 4
Android Topics Limited Resources and why we need to consider them.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Developer Fundamentals V2
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android SDK & App Development
CIS 470 Mobile App Development
Android Project Structure, App Resources and Event Handling
Objects First with Java
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
User Interface Screen Elements
CMPE419 Mobile Application Development
CS 240 – Advanced Programming Concepts
Cosc 5/4730 EmojiCompat library..
Lasalle-App Tecnología Móvil.
CIS 470 Mobile App Development
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

CS323 Android Model-View-Controller Architecture Practice: Build an App TextView vs. EditView

Model-View-Controller (MVC) Architecture Mobile applications rely on the MVC architecture. App objects are assigned one of three roles: Model, View, or Controller. Mobile apps have one important rule governing how objects communicate with each other. Example: A background thread cannot communicate with a View object

How does the MVC architecture work? MVC consists of three components, the Model, the View and the Controller.

The Model The Model handles the data in an App. The Model does not care how its data will be displayed or when it will updated.

The View A View component is the visual presentation of data in an App. Example: a TextView is a View object that displays text data on the App interface screen. Users interact using Views. Example: TextView and Button are View objects that users can respond to with actions.

Controller Object A Controller object acts as an intermediary between View components and Model objects. The Controller can request that data be updated within a Model. The Controller can also update the display data shown in the View.

Example How it works: The Controller will intercept the Tap button event, communicate a new increment data to the Counter data object, and update the TextView in the user interface.

MVC Architecture for Tap App Controller: Java code that acts as the conduit between the Counter (Model) and UI Components (Views) Model: Java class that keeps track of Counter data. View: TextView (to display the count) and Button (to register a tap).

Android Structure for Tap App

package com. example. trishcornez package com.example.trishcornez.tapapp; public class Counter { private int mCount; public Counter(){ mCount = 0; } public void addCount(){ mCount++; } public Integer getCount() { return mCount; } } Model: Counter.java

<. xml version="1. 0" encoding="utf-8" <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="0" android:id="@+id/textView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:textSize="60sp" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TAP" android:id="@+id/button" android:layout_centerVertical="true" android:layout_centerHorizontal="true" android:textSize="60sp" android:onClick="countTap" /> </RelativeLayout> View: main_layout.xml

Practice Lab: Complete the Tap App Code the Controller: MainActivity.java Test the App

TextView vs EditText TextView and EditText are both Views TextView is output. EditText is input.

TextView and EditView Example

EditViews