Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources...

18
Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters 1-6

Transcript of Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources...

Page 1: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Lecture 3 agendarevised setupAndroid Studio alt-views & shortcutsreview layouts and resourcesdebugging in Android Studiolifecycle in Androidlab chapters 1-6

Page 2: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Navigating in Android Studioalt-1 is project view (alt-F1 is show it in project view)alt-2 is favorites (including bookmarks and breakpoints)alt-3 is the search view (cntl-shift-F to find)alt-4 run-consolealt-5 is debug alt-6 is android view (ddms, logcat)alt-7 is structure view (see members and methods)alt-9 is changes(VCS) view

Look at the margin of your project

Page 3: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Get helpcntl-shift-A (find anything in Android studio)

Searching (on mac, replace cntrl with command) cntl-F (find something in the local file)cntl-shift-F (find something in the project)

Go to file in code (on mac, replace cntrl with command) cntl-N (go to files typically in src)cntl-shift-n (go to any file, including res)cntl-E (open recent files)

Go to file in project alt-F1

Page 4: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Go to definition cntl-B (go directly to the method definition)

Javadocscntl-Q (open the javadocs)

Live Templatescntl-J

adding your own Live Templates (cntl-shift-A “live template”)

Page 5: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

DebuggingUsing the debugger (alt-5)See bookmarks and breakpoints (alt-2)F11 to toggle bookmark

Using logcat (alt-6)

Using lint and AS analyzer: Analyze || Inspect Code

///TODO this is my todo message

Page 6: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Resources in Android

Page 7: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.
Page 8: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Layouts and resources

Code: Java (or C if you use NDK)Metafiles: AndroidManifest, project.properties, .gitignore. These all describe the project. Resources “anything in android that is not code or metafiles”

Activities have one or more layouts, and all Layouts have a root-ViewGroup. This root-ViewGroup is the container for the Views.

R.java (gen directory) is a bridge between your resources and your code. If you want to interact programmatically with a resource, it must have an id.

Page 9: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.
Page 10: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Inspecting layouts and resources

You can view both xml and design mode in AS.

You can see how it would look on multiple devices || preview all screens, and toggle with remove previews.

Page 11: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Layouts and resources

res directories can have suffixes, such as layout-land, or drawable-hdpi, values-es, etc.

These suffixes allow you to differentiate at RUNTIME depending on the settings, hardware, and configuration of the device.

For example, if your device is in landscape mode, it'll try to fetch the layout from layout-land first, then it will try to fetch the layout from layout. Vice versa as well; if it's in portait mode, it'll try for layout-port, then layout.

shown in preview mode of resource and rotate device

Page 12: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

Lifecycle in Android

Page 13: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.
Page 14: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.
Page 15: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.
Page 16: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

video: geoQuizz03.webm start 12:30

slides: from bc03

If you (config change) or the OS must bounce your activity, it'll crawl the root-ViewGroup and place the data about the activity into the bundle.

In labGeoQuiz bc03 we are putting the mCurrentIndex in the bundle so that if the user rotates his/her phone in the middle of the quiz, then it'll keep it's place.

Page 17: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

labGeoQuiz

Page 18: Lecture 3 agenda revised setup Android Studio alt-views & shortcuts review layouts and resources debugging in Android Studio lifecycle in Android lab chapters.

how to copy files from a bc branch to a lb branch

Actions || Open in Terminal

git checkout c7c7 res/drawable-*/.

git checkout c7c7 res/values/str*

before a commit you may remove from stage, then:discard: for existing files that you want to roll backremove: for new files that you want to delete