User Interface Layout Interaction. EventsEvent Handlers/Listeners Interacting with a user.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Advertisements

By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
App Development on Android. Contents  First Milestone  Second Milestone  Third Milestone  Last Milestone 
Programming with Android: Android Fragments Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
1 Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources, Listener 10/9/2012 Y. Richard Yang.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Simplify! The Android User Interface
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Android – Fragments L. Grewe.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Field Trip #32 Digital Alarm Clock By Keith Lynn.
Import import android.graphics.Bitmap; import android.widget.ImageView;
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
User Interface Android Club Agenda Button OnClickListener OnLongClickListener ToggleButton Checkbox RatingBar AutoCompleteTextView.
데이터 저장 & Fragment UNIT 28 로봇 SW 콘텐츠 교육원 조용수. 데이터 저장 & Fragment SharedPreference 로 데이터 저장 Fragment 의 이해 2.
CompSci Event Handling. CompSci Event Handling The Plan  Sequential (Single Thread) Model  Event Model  Making the GUI interactive  Examples.
Handling View Events. Open the *MainActivity.java* which is the Activity that hosts the layout in "activity_main.xml". The setContentView method inside.
Video Games list lab 6  At the end of this lab you will be expected to know:  What Views, View Groups, Layouts, and Widgets are and how they relate to.
ANDROID – A FIRST PROGRAM L. Grewe Using AndroidStudio –basic Android  Lets do a “Hello World Project”  Start up AndroidStudio (assume you have installed.
Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences.
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Activities and Intents Richard S. Stansbury 2015.
Designing user interfaces using: Simple views 1. Views Basic views – TextView – EditText – Button – ImageButton – CheckBox – ToggleButton – RadioButton.
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Cosc 4735 Activities, fragments, callbacks/listeners/interfaces.
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
Field Trip #30 A Memory Game By Keith Lynn. View A View is the basic building block of an app Some Views hold other views An example of this is GridLayout.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Java for android Development Nasrullah Khan. Using instanceof in Android Development the classes such as Button, TextView, and CheckBox, which represent.
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 –
CHAPTER 1 Part 2 Android Programming. Chapter objectives: Understand how to create a simple Android project Understand how to create a manifest file Understand.
Fragments and Menus Chapter 4 1. Objectives Learn three different types of menus: options, context, and popup Learn to configure the ActionBar and Toolbar.
CompSci 230 S Programming Techniques
Chapter 2: Simplify! The Android User Interface
Activity and Fragment.
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
Android – Event Handling
Android Widgets 1 7 August 2018
android architecture components with mvvm
ANDROID UI – FRAGMENTS UNIT II.
Android 16: Input Events Kirk Scott.
Picasso Revisted.
Chapter 3: Coding the GUI Programmatically, Layout Managers
Android Programming Lecture 6
Depreciation App: Demo of tabs
CIS 470 Mobile App Development
Introduction to Event Handling
CMPE419 Mobile Application Development
UNIT 08 그림책 만들기 2/2 로봇 SW 콘텐츠 교육원 조용수.
Android Topics Custom ArrayAdapters Creating an Event Listener
Android Developer Fundamentals V2
CIS 470 Mobile App Development
ארועים ומאזינים android.
Android Project Structure, App Resources and Event Handling
Mobile Programmming Dr. Mohsin Ali Memon.
Activities and Fragments
CS 240 – Advanced Programming Concepts
Android Sensor Programming
UI Elements 2.
Presentation transcript:

User Interface Layout Interaction

EventsEvent Handlers/Listeners Interacting with a user.

The root of GUI elements is the View class. UI elements such as Buttons Labels Editable text Images Etc derive from the View class. We define our app’s response to a click by implementing an instance of View.OnClickListener interface. Handling Clicks public class View{ … //nested class public interface OnClickListener { void onClick(View v); } … }

Click Handler idioms: 1. Have the class that owns the GUI element implement the OnClickListener interface. 2. Create an anonymous class that implements OnClickListener interface. 3. Create an anonymous class that implements OnClickListener interface.

public class PixFragment extends Fragment implements public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View v = inflater.inflate(R.layout.pix_frag_layout, container, false); ImageView mSplashView = (ImageView)v.findViewById(R.id.pix_view); mSplashView.setOnClickListener(this); return v; } public void onClick(View v){ // handle the click Log.d("PixFragment", "I was clicked"); } 1. Have the class that owns the GUI element implement the OnClickListener interface.

2 Create an anonymous class that implements OnClickListener interface. public class PixFragment extends Fragment{ private View.OnClickListener mSplashViewListener = new View.OnClickListener() public void onClick(View v) { // handle the click Log.d("PixFragment", "I was clicked"); } } public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View v = inflater.inflate(R.layout.pix_frag_layout, container, false); ImageView mSplashView = (ImageView)v.findViewById(R.id.pix_view); mSplashView.setOnClickListener(mSplashViewListener); return v; }

3 Create an anonymous class that implements OnClickListener interface. public class PixFragment extends Fragment implements public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View v = inflater.inflate(R.layout.pix_frag_layout, container, false); ImageView mSplashView = (ImageView)v.findViewById(R.id.pix_view); mSplashView.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ // handle the click Log.d("PixFragment", "I was clicked"); } }) ; return v; }

2. Create a standalone class that implements OnClickListener interface. import android.view.View.OnClickListener; public class PixFragment extends Fragment{{ public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View v = inflater.inflate(R.layout.pix_frag_layout, container, false); {... Button button = (Button)findViewById(R.id.corky); button.setOnClickListener(new MyClickListener()); … return v; }... //Inner class private class MyClickListener implements OnClickListener implements OnClickListener { public void onClick(View v) { // do something when the button is clicked }