mobile development workshop
play

Mobile Development Workshop ANDROID REFRESHER Overview The - PowerPoint PPT Presentation

Mobile Development Workshop ANDROID REFRESHER Overview The Android operating system Views, Layouts and Activities Event listeners Using Intents to request actions First up Start a new project in Android Studio Call it Before and After


  1. Mobile Development Workshop ANDROID REFRESHER

  2. Overview The Android operating system Views, Layouts and Activities Event listeners Using Intents to request actions

  3. First up… Start a new project in Android Studio Call it Before and After

  4. What is Android? Android is a mobile operating system developed by Google Is it based on the Linux kernel Is uses Java as a main development language

  5. How do you create Android applications? You write applications for Android using the SDK which is built in Java ◦ Writing Android applications require knowledge of Java and an understanding of Object Oriented Development principles ◦ There is also an NDK that allows you to write applications in C ◦ Many parties are constantly exploring extending Android’s available development languages Java’s SDK is essentially a framework that packages the main facets of an Android application You write apps by tying together and extending various components of the framework

  6. Views The basic building blocks of a User Interface Responsible for drawing the interface and responding to events

  7. Some common views

  8. Layouts Special types of views that hold other views Invisible Each layout type have different rules and properties for positioning their child views Layouts form the visible aspect of activities

  9. Popular layouts Linear Layout ◦ Orders its child view sequentially either horizontally or vertically Relative Layout ◦ Arranges its children in relation to itself as well as other children WebView ◦ Displays HTML content (the stuff websites are made of) FrameLayout ◦ Arranges its children along the Z-axis (stacks views on top of each other)

  10. Back to your program… Change the layout of your main activity to use a LinearLayout with vertical orientation Add a button as the LinearLayout’s first child Add a FrameLayout as the LinearLayout’s second child Add a SeekBar (slider) as the LinearLayout’sthird child Add two ImageViews as children of the FrameLayout

  11. Activities An Android application is a collection of components An Activity is one of the main components of Android ◦ contains application logic (code) Applications generally consist of one or more activities ◦ One activity is delegated as the Main activity ◦ The main activity is started automatically when the application is started

  12. Events Events are triggered when a user interacts with a view Event listeners are used to specify what should happen when a particular event takes place Many standard event listeners are found inside the View class

  13. Event listener callbacks Android provides many View.On*Listener classes with appropriate callback methods onClick ◦ Called when the user touches the view onLongClick ◦ Called when the user touches and holds the view onFocusChange ◦ Called when a user navigate to, or away from a view

  14. Back to your program… Bind the views inside your layout to variables inside your activity Add an OnClickListner object to your button ◦ When the button is clicked call an intent to have the camera take a picture ◦ When thee image is returned, set it as the image resource of the first ImageView inside your frame layout

  15. Into to intents A messaging object used to request that action be taken Generally used to Start components such as activities Send information from one component to another

  16. Intents in action

  17. To create an Intent Two types ◦ Explicit ◦ Provide context ◦ Specify a recipient ◦ Implicit ◦ Specify an action

  18. Back to your program… Extend the initial functionality of the button click We’re going to request a picture be taken two times Assign each returned picture to respective ImageView

  19. Finally… Add a OnChange listener to your slider Use the progress of the slider to set the alpha of the ImageView on top in your frame layout

Recommend


More recommend