Custom Views in Android Tutorial
|
|
- Robyn Warner
- 5 years ago
- Views:
Transcription
1 Custom Views in Android Tutorial The Android platform provides an extensive range of user interface items that are sufficient for the needs of most apps. However, there may be occasions on which you feel the need to implement a custom user interface for a project you are working on. In this tutorial we will work through the process of creating a custom View. To create and use our custom View, we will extend the View class, define and specify some custom attributes, add the View to our layout XML, override the ondraw method to tailor the View appearance and manipulate it from our app s main Activity. Step 1: Create an Android Project Create a new Android project in Eclipse. You can choose whatever settings you like as long as your app has a main Activity class and a layout file for it. We do not need any amendments to the Manifest file. Step 2: Create a View Class Our custom View can extend any of the existing Android View classes such as Button or TextView. However, we will create a direct subclass of View. Extending an existing class allows you to use the existing functionality and styling associated with that class, while providing processing to suit your own additional needs. Create a new class in your application by selecting the app s main package in Eclipse and choosing File, New, Class. Enter a name of your choice (good one to use: GoodView) and click Finish. Make your new class extend View by adding to its opening declaration line as follows: public class GoodView extends View { Add the following import statements above this: import android.content.context;
2 import android.content.res.typedarray; import android.graphics.canvas; import android.graphics.paint; import android.graphics.paint.style; import android.util.attributeset; import android.view.view; Step 3: Create Attribute Resources In order to use our custom View as we would use a standard View (i.e. set its attributes in layout XML and refer to them in our Java code), we will declare attribute resources. In Eclipse, create a new file in your project res/values folder by selecting it and choosing File, New, Other, Android XML Values File. Enter attrs as the file name and click Finish as the following screen shots show:
3 In the attributes file we first need to indicate that we are listing resources, so add the following parent element: <resources> </resources> Inside this element, we are going to declare three attributes for the View that will allow us to style it. Let s keep things relatively simple the View is going to display a circle with some text in the middle. The three attributes will be the circle color, the text String, and the text color. Add the following inside your resources element: <declare-styleable name="goodview"> <attr name="circlecolor" format="color" /> <attr name="circlelabel" format="string"></attr> <attr name="labelcolor" format="color"></attr> </declare-styleable> The declare-styleable element specifies the View name. Each attribute has a name and format. We will be able to specify these attributes in the layout XML when we add the custom View and also retrieve them in the View class. We will also be able to retrieve and set the attributes from our Java Activity class. The values provided for each attribute will need to be of the type listed here as format.
4 Step 4: Add the View to the Layout Let s add an instance of the custom View to our app s main layout file. In order to specify the custom View and its attributes, we need to add an attribute to the parent layout element. In the default project, it is a RelativeLayout but you can use whichever type you prefer. Add the following attribute to your layout s parent element: xmlns:custom=" ew" Alter the package name to reflect the package your app is in. This specifies the namespace for our app, allowing us to use the attributes we defined within it. Now we can add an instance of the new View. Inside the layout, add it as follows: <edu.itu.customview.goodview android:id="@+id/custview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="5dp" custom:circlecolor="#ff0099" custom:circlelabel="hello" custom:labelcolor="#ffff66" /> Again, alter the package name to suit your own, and the class name if necessary. We will use the ID to refer to the View in our Activity code. Notice that the element lists standard View attributes alongside custom attributes. The custom attributes are preceded by custom: and use the names we specified in our attributes XML file. Note also that we have specified values of the types we indicated using the format attributes in the attrs.xml file. We will retrieve and interpret these values in our View class. Step 5: Retrieve the Attributes Now let s turn back to the View class we created. Inside the class declaration, add some instance variables as follows: //circle and text colors private int circlecol, labelcol;
5 //label text private String circletext; //paint for drawing custom view private Paint circlepaint; We will use the first three of these to keep track of the current settings for color and text. The Paint object is for when we draw the View. After these variables, add a constructor method for your class: public GoodView (Context context, AttributeSet attrs) { super(context, attrs); As we are extending the View class, the first thing we do is call the superclass method. After the super call, let s extend the method to setup the View. Still in the constructor method, first instantiate the Paint object: //paint object for drawing in ondraw circlepaint = new Paint(); Now let s retrieve the attribute values we set in XML: //get the attributes specified in attrs.xml using the name we included TypedArray a = context.gettheme().obtainstyledattributes(attrs, R.styleable.GoodView, 0, 0); This typed array will provide access to the attribute values. Notice that we use the resource name we specified in the attrs.xml file. Let s now attempt to retrieve the attribute values, using a try block in case anything goes wrong: try { //get the text and colors specified using the names in attrs.xml circletext = a.getstring(r.styleable.goodview_circlelabel); circlecol = a.getinteger(r.styleable.goodview_circlecolor, 0); //0 is default labelcol = a.getinteger(r.styleable.goodview_labelcolor, 0);
6 finally { a.recycle(); We read the attributes into our instance variables. Notice that we use the names we listed for each in attrs.xml again. The colors are retrieved as integer values and the text label as a String. That s the constructor method complete by the time it has executed, the class should have retrieved the selected View attributes we defined in the attribute resources file and set values for in the layout XML. Step 6: Draw the View Now we have our View attributes in the class, so we can go ahead and draw it. To do this, we need to override the ondraw method. Add its outline after your constructor method as protected void ondraw(canvas canvas) { //draw the View Since we re going to draw a circle, let s get some information about the available space, inside the ondraw method: //get half of the width and height as we are working with a circle int viewwidthhalf = this.getmeasuredwidth()/2; int viewheighthalf = this.getmeasuredheight()/2; Now we can calculate the circle radius: //get the radius as half of the width or height, whichever is smaller //subtract ten so that it has some space around it int radius = 0; if(viewwidthhalf>viewheighthalf) radius=viewheighthalf-10; else
7 radius=viewwidthhalf-10; Now let s set some properties for painting with: circlepaint.setstyle(style.fill); circlepaint.setantialias(true); Now we will use the selected circle color as stored in our instance variable: //set the paint color using the circle color specified circlepaint.setcolor(circlecol); This means that the circle will be drawn with whatever color we listed in the layout XML. Let s draw it now using these details: canvas.drawcircle(viewwidthhalf, viewheighthalf, radius, circlepaint); Now let s add the text. First set the color using the value retrieved from the layout XML: //set the text color using the color specified circlepaint.setcolor(labelcol); Now set some more properties: //set text properties circlepaint.settextalign(paint.align.center); circlepaint.settextsize(50); Finally we can draw the text, using the text string retrieved: //draw the text using the string attribute and chosen properties canvas.drawtext(circletext, viewwidthhalf, viewheighthalf, circlepaint); That s ondraw complete. Run the program now and make sure you see the following output:
8 Step 7: Provide Get and Set Methods When you create a custom View with your own attributes, it is recommended that you also provide get and set methods for them in your View class. After the ondraw method, first add the get methods for the three customizable attributes: public int getcirclecolor(){ return circlecol; public int getlabelcolor(){ return labelcol; public String getlabeltext(){ return circletext;
9 Each method simply returns the value requested. Now add the set methods for the color attributes: public void setcirclecolor(int newcolor){ //update the instance variable circlecol=newcolor; //redraw the view invalidate(); requestlayout(); public void setlabelcolor(int newcolor){ //update the instance variable labelcol=newcolor; //redraw the view invalidate(); requestlayout(); These methods accept int parameters representing the color to set. In both cases we update the instance variable in question, then prompt the View to be redrawn. This will make the ondraw method execute again, so that the new values affect the View displayed to the user. Now add the set method for the text: public void setlabeltext(string newlabel){ //update the instance variable circletext=newlabel; //redraw the view invalidate(); requestlayout(); This is the same as the other two set methods except for the String parameter. We will call on these methods in our Activity class next. Step 8: Manipulate the View from the Activity
10 Now we have the basics of our custom View in place, let s demonstrate using the methods within our Activity class. In the app s main Activity class, add the following import statements: import android.graphics.color; import android.view.view; Before the oncreate method, inside the class declaration, add an instance variable representing the instance of the custom View displayed: private GoodView myview; Inside the oncreate method, after the existing code, retrieve this using its ID as included in the XML layout file: myview = (GoodView)findViewById(R.id.custView); To demonstrate setting the View attribute values from the Activity, we will add a simple button. Open your layout file and add it after the custom View element: <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:onclick="btnpressed" android:text="@string/btn_label" /> We specify a method to execute on user clicks we will add this to the Activity class. First add the String to your res/values/strings XML file: <string name="btn_label">press Me</string> Check to make sure the button shows by running your app again.
11 Now go back to the Activity class and add the method listed for clicks on the button. Let s use the set methods we defined to update the custom View appearance: public void btnpressed(view view){ myview.setcirclecolor(color.green); myview.setlabelcolor(color.magenta); myview.setlabeltext("help"); This is of course just to demonstrate how you can interact with a custom View within your Activity code. When the user clicks the button, the appearance of the custom View will change.
12 Conclusion In general, it s advisable to use existing Android View classes where possible. However, if you do feel that you need a level of customization beyond the default settings, creating your own custom Views is typically straightforward. What we have covered in this tutorial is really just the beginning when it comes to creating tailored Android user interfaces.
package import import import import import import import public class extends public void super new this class extends public super public void new
Android 2-D Drawing Android uses a Canvas object to host its 2-D drawing methods. The program below draws a blue circle on a white canvas. It does not make use of the main.xml layout but draws directly
More informationGATAV 5. Animations Using a Game Loop
GATAV 5. Animations Using a Game Loop TOC 1. The basic principle. 2. Creating bubbles. 3. Making the bubbles more look alive. 4. The appearent look. 5. Making the audiance impressed. 6. Now it up to you:
More informationANDROID (4) 2D Graphics and Animation, Handling Screen Rotation. Marek Piasecki
ANDROID (4) 2D Graphics and Animation, Handling Screen Rotation Marek Piasecki Outline 2D graphics drawing Color / Paint / Canvas XML drawable (from resources) direct to a Canvas / View.onDraw() 2D animation
More informationINTRODUCTION TO ANDROID
INTRODUCTION TO ANDROID 1 Niv Voskoboynik Ben-Gurion University Electrical and Computer Engineering Advanced computer lab 2015 2 Contents Introduction Prior learning Download and install Thread Android
More informationAndroid Apps Development for Mobile Game Lesson Create a simple paint brush that allows user to draw something (Page 11 13)
Workshop 1. Create a simple Canvas view with simple drawing (Page 1 5) Hide Action Bar and Status Bar Create Canvas View Create Simple Drawing 2. Create a simple animation (Page 6 10) Load a simple image
More informationProgramming Mobile Applications with Android Lab2
Programming Mobile Applications Lab2 22-26 September, Albacete, Spain Jesus Martínez-Gómez .- Create, compile and execute an Android application to understand the Android life cycle Follow the instructions
More informationAndroid App Development. Mr. Michaud ICE Programs Georgia Institute of Technology
Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based
More informationDatabase Development In Android Applications
ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran
More informationAndroid Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]
s@lm@n Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ] Android AND-401 : Practice Test Question No : 1 Which of the following is required to allow the Android
More informationOPTIMIZING ANDROID UI PRO TIPS FOR CREATING SMOOTH AND RESPONSIVE APPS
OPTIMIZING ANDROID UI PRO TIPS FOR CREATING SMOOTH AND RESPONSIVE APPS @CYRILMOTTIER GET TO KNOW JAVA DON T USE BOXED TYPES UNNECESSARILY HashMap hashmap = new HashMap();
More information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More informationEECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)
EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget
More informationMobile Application (Design and) Development
Mobile Application (Design and) Development 7 th class Prof. Stephen Intille s.intille@neu.edu Northeastern University 1 Q&A Workspace setup in lab. Anyone try it? Anyone looking for a partner? Boggle
More informationEECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University
EECS 4443 Mobile User Interfaces More About Layouts Scott MacKenzie York University Overview (Review) A layout defines the visual structure for a user interface, such as the UI for an activity or app widget
More informationELET4133: Embedded Systems. Topic 15 Sensors
ELET4133: Embedded Systems Topic 15 Sensors Agenda What is a sensor? Different types of sensors Detecting sensors Example application of the accelerometer 2 What is a sensor? Piece of hardware that collects
More informationAndroid HelloWorld - Example. Tushar B. Kute,
Android HelloWorld - Example Tushar B. Kute, http://tusharkute.com Anatomy of Android Application Anatomy of Android Application Java This contains the.java source files for your project. By default, it
More informationProgramming of Mobile Services, Spring 2012
Programming of Mobile Services, Spring 2012 HI1017 Lecturer: Anders Lindström, anders.lindstrom@sth.kth.se Lecture 6 Today s topics Android graphics - Views, Canvas, Drawables, Paint - Double buffering,
More informationMore About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario
More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario The Story So Far... Classes as collections of fields and methods. Methods can access fields, and
More informationMobile App Design Project Doodle App. Description:
Mobile App Design Project Doodle App Description: This App takes user touch input and allows the user to draw colored lines on the screen with touch gestures. There will be a menu to allow the user to
More informationLab 3. Accessing GSM Functions on an Android Smartphone
Lab 3 Accessing GSM Functions on an Android Smartphone 1 Lab Overview 1.1 Goals The objective of this practical exercise is to create an application for a smartphone with the Android mobile operating system,
More informationSpring Lecture 7 Lecturer: Omid Jafarinezhad
Mobile Programming Sharif University of Technology Spring 2016 - Lecture 7 Lecturer: Omid Jafarinezhad Grid View GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid
More informationEmbedded Systems Programming - PA8001
Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 9 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering
More informationPractical 1.ListView example
Practical 1.ListView example In this example, we show you how to display a list of fruit name via ListView. Android Layout file File : res/layout/list_fruit.xml
More informationUser Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.
User Interface Development CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath 1 Outline UI Support in Android Fragments 2 UI Support in the Android
More informationCSE 331 Software Design & Implementation
CSE 331 Software Design & Implementation Kevin Zatloukal Summer 2017 Java Graphics and GUIs (Based on slides by Mike Ernst, Dan Grossman, David Notkin, Hal Perkins, Zach Tatlock) Review: how to create
More informationELET4133: Embedded Systems. Topic 3 Eclipse Tour & Building a First App
ELET4133: Embedded Systems Topic 3 Eclipse Tour & Building a First App Agenda In this class we will look at the Eclipse IDE We will examine it s various parts when working on an application We will load
More informationAn Android Studio SQLite Database Tutorial
An Android Studio SQLite Database Tutorial Previous Table of Contents Next An Android Studio TableLayout and TableRow Tutorial Understanding Android Content Providers in Android Studio Purchase the fully
More informationCS260 Intro to Java & Android 09.AndroidAdvUI (Part I)
CS260 Intro to Java & Android 09.AndroidAdvUI (Part I) Winter 2015 Winter 2015 CS260 - Intro to Java & Android 1 Creating TicTacToe for Android We are going to begin to use everything we ve learned thus
More informationICS 4U. Introduction to Programming in Java. Chapter 10 Notes
ICS 4U Introduction to Programming in Java Chapter 10 Notes Classes and Inheritance In Java all programs are classes, but not all classes are programs. A standalone application is a class that contains
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationAssistant Professor Computer Science. Introduction to Human-Computer Interaction
CMSC434 Introduction to Human-Computer Interaction Week 08 Lecture 16 Oct 23, 2014 Building Android UIs II Implementing Custom Views Human Computer Interaction Laboratory @jonfroehlich Assistant Professor
More informationChapter 3: Inheritance and Polymorphism
Chapter 3: Inheritance and Polymorphism Overview Inheritance is when a child class, or a subclass, inherits, or gets, all the data (properties) and methods from the parent class, or superclass. Just like
More informationVienos veiklos būsena. Theory
Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is
More informationFragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment
FRAGMENTS Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each
More informationChapter 1: Object-Oriented Programming Using C++
Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms
More informationProgramming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna
Programming with Android: Introduction Layouts Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Views: outline Main difference between a Drawable and
More informationJava for Non Majors Spring 2018
Java for Non Majors Spring 2018 Final Study Guide The test consists of 1. Multiple choice questions - 15 x 2 = 30 points 2. Given code, find the output - 3 x 5 = 15 points 3. Short answer questions - 3
More informationAgenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen
Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing
More informationMastering Android Drawables
Cyril Mottier Mastering Android Drawables Drawable are powerful so use them! Global note 2 Introduction Drawables 101 3 Introduction What s a Drawable? 4 Introduction What s a Drawable? Entity that can
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationANDROID USER INTERFACE
1 ANDROID USER INTERFACE Views FUNDAMENTAL UI DESIGN Visual interface element (controls or widgets) ViewGroup Contains multiple widgets. Layouts inherit the ViewGroup class Activities Screen being displayed
More informationAndroid Development Tutorial
Android Development Tutorial Part II Human-Computer Interaction (COMP 4020) Winter 2013 2 Canvas Example public class CanvasApp extends Activity @Override protected void oncreate(bundle savedinstancestate)
More informationStanislav Rost CSAIL, MIT
Session 2: Lifecycles, GUI Stanislav Rost CSAIL, MIT The Plan 1 Activity lifecycle Service lifecycle 2 Selected GUI elements UI Layouts 3 Hands on assignment: RoboChat Application GUI Design Birth, death,
More informationANDROID APPS (NOW WITH JELLY BEANS!) Jordan Jozwiak November 11, 2012
ANDROID APPS (NOW WITH JELLY BEANS!) Jordan Jozwiak November 11, 2012 AGENDA Android v. ios Design Paradigms Setup Application Framework Demo Libraries Distribution ANDROID V. IOS Android $25 one-time
More informationCSSE 220 Day 15. Inheritance. Check out DiscountSubclasses from SVN
CSSE 220 Day 15 Inheritance Check out DiscountSubclasses from SVN Discount Subclasses Work in pairs First look at my solution and understand how it works Then draw a UML diagram of it DiscountSubclasses
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationUser Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University
User Interface: Layout Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University http://twitter.com/krunapon Agenda User Interface Declaring Layout Common Layouts User Interface
More informationTopic 7: Algebraic Data Types
Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,
More informationAndroid Application Development. By : Shibaji Debnath
Android Application Development By : Shibaji Debnath About Me I have over 10 years experience in IT Industry. I have started my career as Java Software Developer. I worked in various multinational company.
More informationCreating a User Interface
Creating a User Interface Developing for Android devices is a complicated process that requires precision to work with. Android runs on numerous devices from smart-phones to tablets. Instead of using a
More informationObject-Oriented Programming Concepts
Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are
More informationHomework 6. Yuji Shimojo CMSC 330. Instructor: Prof. Reginald Y. Haseltine
Homework 6 Yuji Shimojo CMSC 330 Instructor: Prof. Reginald Y. Haseltine July 21, 2013 Question 1 What is the output of the following C++ program? #include #include using namespace
More informationContents at a Glance. iii.
For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author...ix
More informationChapter 10 Classes Continued. Fundamentals of Java
Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an
More informationAndroid development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.
Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code
More informationAndroid Application Development Instructions
Android Application Development Instructions Created by Bryan Van Draanen With help from Kevin Z. UW CSE 331 Software Design and Implementation Summer 2017 1 Table of Contents 1. Downloading and Installing
More informationCS260 Intro to Java & Android 05.Android UI(Part I)
CS260 Intro to Java & Android 05.Android UI(Part I) Winter 2015 Winter 2015 CS250 - Intro to Java & Android 1 User Interface UIs in Android are built using View and ViewGroup objects A View is the base
More informationGUI Design for Android Applications
GUI Design for Android Applications SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November
More informationChapter 14 Abstract Classes and Interfaces
Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden
More informationCS260 Intro to Java & Android 05.Android UI(Part I)
CS260 Intro to Java & Android 05.Android UI(Part I) Winter 2018 Winter 2018 CS250 - Intro to Java & Android 1 User Interface UIs in Android are built using View and ViewGroup objects A View is the base
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationUnderstand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good
More informationAn applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a
CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II) Media Playback Engine Android provides a media playback engine at the native level called Stagefright that comes built-in with software-based
More informationBuilding User Interface for Android Mobile Applications II
Building User Interface for Android Mobile Applications II Mobile App Development 1 MVC 2 MVC 1 MVC 2 MVC Android redraw View invalidate Controller tap, key pressed update Model MVC MVC in Android View
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationIST311. Advanced Issues in OOP: Inheritance and Polymorphism
IST311 Advanced Issues in OOP: Inheritance and Polymorphism IST311/602 Cleveland State University Prof. Victor Matos Adapted from: Introduction to Java Programming: Comprehensive Version, Eighth Edition
More informationCreating a Custom ListView
Creating a Custom ListView References https://developer.android.com/guide/topics/ui/declaring-layout.html#adapterviews Overview The ListView in the previous tutorial creates a TextView object for each
More information1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'
Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java
More informationContents. Orientation SearchBar and Gallery List Advanced Multiple Form Multi Touch Animations Layout Designing UI using UI Builder
Advanced UI Contents Orientation SearchBar and Gallery List Advanced Multiple Form Multi Touch Animations Layout Designing UI using UI Builder Introduction Advanced UI Concepts A detailed view of controls
More informationProgramming: You will have 6 files all need to be located in the dir. named PA4:
PROGRAMMING ASSIGNMENT 4: Read Savitch: Chapter 7 and class notes Programming: You will have 6 files all need to be located in the dir. named PA4: PA4.java ShapeP4.java PointP4.java CircleP4.java RectangleP4.java
More informationEMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches
EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed
More informationAndroid/Java Lightning Tutorial JULY 30, 2018
Android/Java Lightning Tutorial JULY 30, 2018 Java Android uses java as primary language Resource : https://github.mit.edu/6178-2017/lec1 Online Tutorial : https://docs.oracle.com/javase/tutorial/java/nutsandbolts/inde
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module
More informationTheme 2 Program Design. MVC and MVP
Theme 2 Program Design MVC and MVP 1 References Next to the books used for this course, this part is based on the following references: Interactive Application Architecture Patterns, http:// aspiringcraftsman.com/2007/08/25/interactiveapplication-architecture/
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More informationInteraction with Android
Interaction with Android The Android program can output data by working with the xml files. The main use of the java files is to get some data, make decisions and change the output based on the results
More informationAndroid Basics. Android UI Architecture. Android UI 1
Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à
More informationListView Containers. Resources. Creating a ListView
ListView Containers Resources https://developer.android.com/guide/topics/ui/layout/listview.html https://developer.android.com/reference/android/widget/listview.html Creating a ListView A ListView is a
More informationDeveloping Android Applications Introduction to Software Engineering Fall Updated 1st November 2015
Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 1st November 2015 Android Lab 3 & Midterm Additional Concepts No Class Assignment 2 Class Plan Android : Additional
More informationA Crash Course to Android Mobile Platform
Enterprise Application Development using J2EE Shmulik London Lecture #2 A Crash Course to Android Mobile Platform Enterprise Application Development Using J2EE / Shmulik London 2004 Interdisciplinary Center
More informationImplementing Graphical User Interfaces
Chapter 6 Implementing Graphical User Interfaces 6.1 Introduction To see aggregation and inheritance in action, we implement a graphical user interface (GUI for short). This chapter is not about GUIs,
More informationPROGRAMMING APPLICATIONS DECLARATIVE GUIS
PROGRAMMING APPLICATIONS DECLARATIVE GUIS DIVING RIGHT IN Eclipse? Plugin deprecated :-( Making a new project This keeps things simple or clone or clone or clone or clone or clone or clone Try it
More informationDeclarations and Access Control SCJP tips
Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for
More information5.6.1 The Special Variable this
ALTHOUGH THE BASIC IDEAS of object-oriented programming are reasonably simple and clear, they are subtle, and they take time to get used to And unfortunately, beyond the basic ideas there are a lot of
More informationIntents. Your first app assignment
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
More informationCS/ENGRD 2110 SPRING 2018
CS/ENGRD 2110 SPRING 2018 Lecture 7: Interfaces and http://courses.cs.cornell.edu/cs2110 1 2 St Valentine s Day! It's Valentines Day, and so fine! Good wishes to you I consign.* But since you're my students,
More informationF I N A L E X A M I N A T I O N
Faculty Of Computer Studies M257 Putting Java to Work F I N A L E X A M I N A T I O N Number of Exam Pages: (including this cover sheet( Spring 2011 April 4, 2011 ( 5 ) Time Allowed: ( 1.5 ) Hours Student
More informationJava Programming Tutorial 1
Java Programming Tutorial 1 Every programming language has two defining characteristics: Syntax Semantics Programming Writing code with good style also provides the following benefits: It improves the
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationAndroid - Widgets Tutorial
Android - Widgets Tutorial A widget is a small gadget or control of your android application placed on the home screen. Widgets can be very handy as they allow you to put your favourite applications on
More informationXML Tutorial. NOTE: This course is for basic concepts of XML in line with our existing Android Studio project.
XML Tutorial XML stands for extensible Markup Language. XML is a markup language much like HTML used to describe data. XML tags are not predefined in XML. We should define our own Tags. Xml is well readable
More informationIntroduction to Android Development
Introduction to Android Development What is Android? Android is the customizable, easy to use operating system that powers more than a billion devices across the globe - from phones and tablets to watches,
More informationObject Oriented Programming. Java-Lecture 11 Polymorphism
Object Oriented Programming Java-Lecture 11 Polymorphism Abstract Classes and Methods There will be a situation where you want to develop a design of a class which is common to many classes. Abstract class
More informationEventually, you'll be returned to the AVD Manager. From there, you'll see your new device.
Let's get started! Start Studio We might have a bit of work to do here Create new project Let's give it a useful name Note the traditional convention for company/package names We don't need C++ support
More informationCIS 110: Introduction to computer programming
CIS 110: Introduction to computer programming Lecture 25 Inheritance and polymorphism ( 9) 12/3/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline Inheritance Polymorphism Interfaces 12/3/2011
More informationAndroid Beginners Workshop
Android Beginners Workshop at the M O B IL E M O N D AY m 2 d 2 D E V E L O P E R D A Y February, 23 th 2010 Sven Woltmann, AndroidPIT Sven Woltmann Studied Computer Science at the TU Ilmenau, 1994-1999
More informationTWO-DIMENSIONAL FIGURES
TWO-DIMENSIONAL FIGURES Two-dimensional (D) figures can be rendered by a graphics context. Here are the Graphics methods for drawing draw common figures: java.awt.graphics Methods to Draw Lines, Rectangles
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 4: OO Principles - Polymorphism http://courses.cs.cornell.edu/cs2110/2018su Lecture 3 Recap 2 Good design principles.
More information