Androidmobilių programėlių kūrimo įvadas
Application Fundamentals- Android applications are written in theJava programming language.- The Android operating system ...
Application Components- There are four different types of application components. Each type serves adistinct purpose and h...
ActivityAn activity represents a single screen with auser interface. For example, an emailapplication might have one activ...
Activity LifecycleA representation of how each new activity in a task adds an item to the backstack. When the user presses...
Activity LifecycleonCreate() - Called when the activity is first created. Thisis where you should do all of your normal st...
Activity LifecycleonPause() - Called when the system is about to startresuming another activity. This method is typically ...
FragmentA Fragment represents a behavior or aportion of user interface in an Activity. Youcan combine multiple fragments i...
Fragment LifecycleonAttach() - Called when the fragment has beenassociated with the activity.onCreate() - The system calls...
Fragment LifecycleonPause() - The system calls this method as the firstindication that the user is leaving the fragment (t...
ServiceA Service is an application component that can performlong-running operations in the background and does notprovide...
Content ProviderA content provider manages access to a centralrepository of data. A provider is part of an Androidapplicat...
Broadcast receiversA broadcast receiver is acomponent that responds tosystem-wide broadcastannouncements. Manybroadcasts o...
Intents and Intent FiltersThree of the core components of an application - activities,services, and broadcast receivers - ...
User InterfaceAll user interface elements in anAndroid app are built using Viewand ViewGroup objects.A View is an object t...
User InterfaceAll user interface elements in anAndroid app are built using Viewand ViewGroup objects.A View is an object t...
Linear LayoutLinearLayout is a view group that aligns allchildren in a single direction, vertically orhorizontally. You ca...
Linear Layout ExampleAll children of a LinearLayout arestacked one after the other, so avertical list will only have onech...
Relative LayoutRelativeLayout is a view group that displays childviews in relative positions. The position of eachview can...
Relative Layout ExampleRelativeLayout lets child viewsspecify their position relative tothe parent view or to each other(s...
List ViewListView is a view group that displays a list ofscrollable items. The list items are automaticallyinserted to the...
Grid ViewGridView is a ViewGroup that displays items in atwo-dimensional, scrollable grid. The grid itemsare automatically...
Input ControlsInput controls are the interactive components inyour apps user interface. Android provides awide variety of ...
Buttons          Depending on whether you          want a button with text, an          icon, or both, you can          cr...
Text FieldsInput controls are the interactive components inyour apps user interface. Android provides awide variety of con...
Text FieldsYou can specify the type of keyboard you want for your EditTextobject with the android:inputType attribute.Ther...
Checkboxes / Radio ButtonsCheckboxes allow the user to select one or moreoptions from a set. Typically, you should present...
Setup IDE      http://developer.android.com/tools/
Create Android project
Create Android project
Android project structure            src – Java code            assets – external files            libs – external librari...
MainActivity.java
activity_main.xml / strings.xml
Hello world Result
Create Result Activity Manifest file
Create Result Activity
Update Main Activity
Update Main Activity
Update Main Activity
Q&Av.valkaitis@appcamp.lt
Upcoming SlideShare
Loading in …5
×

"Android" mobilių programėlių kūrimo įvadas #2

583 views

Published on

Antroji mokymų ciklo paskaita apie „Android“ operacinę sistemą, kurįa dėstė UAB „App Camp“ techninis projektų vadovas Vykintas Valkaitis.

Paskaitos temos:

1. Pagrindiniai Android programos komponentai:
- Activity
- Service
- Content Providers
- Broadcast receiver
- Fragment

2. UI koponentai:
- Linear/Relative Layout
- List View
- Grid View
- Button
- Text View
- Checkbox / Radio Button / Toggle Button

3. Drawables:
- Paveiksliukai
- 9 patch Image
- State drawable
- Animacija

4. Dialogai ir Toast

5. Stiliai ir temos

6. Duomenų saugojimas:
- Shared Preferences
- Internal Storage
- External Storage
- SQLite Database
- Network Connection

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
583
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

"Android" mobilių programėlių kūrimo įvadas #2

  1. 1. Androidmobilių programėlių kūrimo įvadas
  2. 2. Application Fundamentals- Android applications are written in theJava programming language.- The Android operating system is amulti-user Linux system in which eachapplication is a different user.- Each process has its own virtualmachine (VM), so an applications coderuns in isolation from other applications.
  3. 3. Application Components- There are four different types of application components. Each type serves adistinct purpose and has a distinct lifecycle that defines how the component iscreated and destroyed:- Activity- Service- Content provider- Broadcast receiver
  4. 4. ActivityAn activity represents a single screen with auser interface. For example, an emailapplication might have one activity thatshows a list of new emails, another activity tocompose an email, and another activity forreading emails.
  5. 5. Activity LifecycleA representation of how each new activity in a task adds an item to the backstack. When the user presses the Back button, the current activity is destroyedand the previous activity resumes.
  6. 6. Activity LifecycleonCreate() - Called when the activity is first created. Thisis where you should do all of your normal static set up —create views, bind data to lists, and so on.onRestart() - Called after the activity has been stopped,just prior to it being started again.onStart() - Called just before the activity becomes visibleto the user.onResume() - Called just before the activity startsinteracting with the user.
  7. 7. Activity LifecycleonPause() - Called when the system is about to startresuming another activity. This method is typically usedto commit unsaved changes to persistent data, stopanimations and other things that may be consumingCPU, and so on. It should do whatever it does veryquickly, because the next activity will not be resumeduntil it returns.onStop() - Called when the activity is no longer visible tothe user.onDestroy() - Called before the activity is destroyed. Thisis the final call that the activity will receive.
  8. 8. FragmentA Fragment represents a behavior or aportion of user interface in an Activity. Youcan combine multiple fragments in a singleactivity to build a multi-pane UI and reuse afragment in multiple activities.
  9. 9. Fragment LifecycleonAttach() - Called when the fragment has beenassociated with the activity.onCreate() - The system calls this when creating thefragment.onCreateView() - The system calls this when its time forthe fragment to draw its user interface for the first time.onActivityCreated() - Called when the activitysonCreate() method has returned.onStart(), onResume() - Same as Activity.
  10. 10. Fragment LifecycleonPause() - The system calls this method as the firstindication that the user is leaving the fragment (though itdoes not always mean the fragment is being destroyed).onStop() - Called when the Fragment is no longer started.onDestroyView() - Called when the view hierarchyassociated with the fragment is being removed.onDestroy() - Called when the fragment is no longer inuse.onDetach() - Called when the fragment is beingdisassociated from the activity.
  11. 11. ServiceA Service is an application component that can performlong-running operations in the background and does notprovide a user interface.Started - A service is "started" when an applicationcomponent (such as an activity) starts it by callingstartService().Bound - A service is "bound" when an applicationcomponent binds to it by calling bindService().A service runs in the main thread of its hosting process -the service does not create its own thread and does notrun in a separate process (unless you specify otherwise).
  12. 12. Content ProviderA content provider manages access to a centralrepository of data. A provider is part of an Androidapplication, which often provides its own UI for workingwith the data.Decide if you need a content provider. You need to builda content provider if you want to provide one or more ofthe following features:- You want to offer complex data or files to otherapplications.- You want to allow users to copy complex data from yourapp into other apps.- You want to provide custom search suggestions usingthe search framework.
  13. 13. Broadcast receiversA broadcast receiver is acomponent that responds tosystem-wide broadcastannouncements. Manybroadcasts originate from thesystem—for example, abroadcast announcing that thescreen has turned off, thebattery is low, or a picture wascaptured.
  14. 14. Intents and Intent FiltersThree of the core components of an application - activities,services, and broadcast receivers - are activated throughmessages, called intents.
  15. 15. User InterfaceAll user interface elements in anAndroid app are built using Viewand ViewGroup objects.A View is an object that drawssomething on the screen that theuser can interact with.A ViewGroup is an object thatholds other View (andViewGroup) objects in order todefine the layout of the interface.
  16. 16. User InterfaceAll user interface elements in anAndroid app are built using Viewand ViewGroup objects.A View is an object that drawssomething on the screen that theuser can interact with.A ViewGroup is an object thatholds other View (andViewGroup) objects in order todefine the layout of the interface.
  17. 17. Linear LayoutLinearLayout is a view group that aligns allchildren in a single direction, vertically orhorizontally. You can specify the layout directionwith the android:orientation attribute.
  18. 18. Linear Layout ExampleAll children of a LinearLayout arestacked one after the other, so avertical list will only have onechild per row, no matter how widethey are, and a horizontal list willonly be one row high (the heightof the tallest child, plus padding).
  19. 19. Relative LayoutRelativeLayout is a view group that displays childviews in relative positions. The position of eachview can be specified as relative to siblingelements (such as to the left-of or below anotherview) or in positions relative to the parentRelativeLayout area (such as aligned to thebottom, left of center).
  20. 20. Relative Layout ExampleRelativeLayout lets child viewsspecify their position relative tothe parent view or to each other(specified by ID). So you canalign two elements by rightborder, or make one belowanother, centered in the screen,centered left, and so on. Bydefault, all child views are drawnat the top-left of the layout, so youmust define the position of eachview using the various layoutproperties available fromRelativeLayout.LayoutParams.
  21. 21. List ViewListView is a view group that displays a list ofscrollable items. The list items are automaticallyinserted to the list using an Adapter that pullscontent from a source such as an array ordatabase query and converts each item resultinto a view thats placed into the list.
  22. 22. Grid ViewGridView is a ViewGroup that displays items in atwo-dimensional, scrollable grid. The grid itemsare automatically inserted to the layout using aListAdapter.
  23. 23. Input ControlsInput controls are the interactive components inyour apps user interface. Android provides awide variety of controls you can use in your UI,such as buttons, text fields, seek bars,checkboxes, zoom buttons, toggle buttons, andmany more.
  24. 24. Buttons Depending on whether you want a button with text, an icon, or both, you can create the button in your layout in three ways.
  25. 25. Text FieldsInput controls are the interactive components inyour apps user interface. Android provides awide variety of controls you can use in your UI,such as buttons, text fields, seek bars,checkboxes, zoom buttons, toggle buttons, andmany more.
  26. 26. Text FieldsYou can specify the type of keyboard you want for your EditTextobject with the android:inputType attribute.There are several different input types available for differentsituations. Here are some of the more common values forandroid:inputType:"text" - Normal text keyboard."textEmailAddress" -Normal text keyboard with the @ character."textUri" - Normal text keyboard with the / character."number" - Basic number keypad."phone" - Phone-style keypad.
  27. 27. Checkboxes / Radio ButtonsCheckboxes allow the user to select one or moreoptions from a set. Typically, you should presenteach checkbox option in a vertical list.Radio buttons allow the user to select one optionfrom a set. You should use radio buttons foroptional sets that are mutually exclusive if youthink that the user needs to see all availableoptions side-by-side.
  28. 28. Setup IDE http://developer.android.com/tools/
  29. 29. Create Android project
  30. 30. Create Android project
  31. 31. Android project structure src – Java code assets – external files libs – external libraries res – application resources AndroidManifest.xml – the "manifest" file
  32. 32. MainActivity.java
  33. 33. activity_main.xml / strings.xml
  34. 34. Hello world Result
  35. 35. Create Result Activity Manifest file
  36. 36. Create Result Activity
  37. 37. Update Main Activity
  38. 38. Update Main Activity
  39. 39. Update Main Activity
  40. 40. Q&Av.valkaitis@appcamp.lt

×