imageNames, int vMargin) {
// Obtain the inflater from the context
LayoutInflater inflater = LayoutInflater.from(context);
// Inflate and attach it as a child of *this* View (ExampleView)
inflater.inflate(R.layout.example, this, true);
}
```
---
# Reminder From Last Week: [Layout Lab](https://gitlab.cs.washington.edu/cse340/exercises/layoutlab/-/tree/master)
- When doing Layout Part3/4: Reference the solution the for the "programmatic" method
- GitHub Link to [Solution](https://gitlab.cs.washington.edu/cse340/exercises/layoutlab/-/blob/jay-solution-with-comments/app/src/main/java/cse340/exercises/layoutlab/ProgrammaticConstraints.java)
---
class: middle, center
# Review
Interactor Hierarchy labeling and drawing trees
Toolkit architecture vs Toolkit library
---
# Review Q1: Drawing Hierarchy
.left-column50[
View Hierarchy question:
- Draw a View Hierarchy based on the screen capture.
- Only include the contents below the top green bar.
]
.right-column50[
![:img Android app showing a vertical list of recent and previous messages, 60%, width](img/examlet_prac_3_layout.png)
]
---
# Review Q1: Drawing Hierarchy
Here's an example of how you should format the View hierarchy
Remember last week's Alarm app example?
.left-column50[
![:img Alarm clock application screenshot and interactor hierarchy, 100%, width](img/alarmclock.png)
]
.right-column50[
![:img Alarm clock view hierarchy, 60%, width](img/viewhierarchy.png)
]
---
# Review Q1: Drawing Hierarchy Answer
.left-column50[
Possible answer:
![:img Possible exam answer showing a hierarchy of Views in the aforementioned example picture, 100%, width](img/examlet_prac_3_ans.png)
]
.right-column50[
![:img Android app showing a vertical list of recent and previous messages, 60%, width](img/examlet_prac_3_layout.png)
]
---
# Review Q2: Parent-Child Order
Regarding the below tree, list the z-order (from bottom to top) they will be drawn in.
graph TD
Parent -->A[Foo]
Parent -->B[Bar]
Parent -->C[Baz]
--
- **1. parent 2. foo 3. bar 4. baz**
---
# Review Q3: Android Methods
- Consider the onMeasure() method that is overridden in Layout Part 3.
- Is this method part of the **toolkit architecture or library?**
---
# Review Q3: Android Methods Answer
- **Answer: Toolkit Architecture**
- "Architecture": the fundamental running code that builds your app
- Includes interactor hierarchy
- Decides structure, redraw, layout, MEASURING stuff!
- Manage your components/app lifecycle
---
# Reminder: Developer roles
graph LR
ip[Interface Programmer]
w[Component Developer]
l[Library Extender]
a[Architecture Extender]
t[Toolkit Builder]
classDef yellow font-size:14pt,text-align:center
classDef green font-size:14pt,text-align:center
classDef darkblue font-size:14pt,text-align:center
class t yellow
class w,l,a green
class ip darkblue
---
# Review: Other Definitions
- [Interface Toolkit](https://courses.cs.washington.edu/courses/cse340/22sp/slides/wk01/first-app.html#31): provides services that help you create things
- Used by your program
- Contains library of components, architecture
- "Library": optional COLLECTION of functions, classes, COMPONENTS... that you can include in your app
- Includes ex: ImageView class, ____View class ...etc
- Third Party Libraries
---
# Calculator App
- [This](https://gitlab.cs.washington.edu/cse340/exercises/mvc-calculator/-/tree/section3-layoutonly) is a simple Android calculator app.
- Clone section 3 branch
- Examine src/main/res/layout/activity_main.xml
- How could you refactor or reorganize this code?
--
- Example: `` tag --> [Android Docs](https://developer.android.com/training/improving-layouts/reusing-layouts)
---
# Section 3 Exercise Submission
- Submit evidence of refactoring.
- Options (can choose all or any):
- Submit XML files (can highlight whichever part they modified) demonstrating your refactor and restyling/added strings
- Screenshot of changes
- Make some text comments on the Edstem submission on what you changed in the code
- Clone your whole repo and upload that zipped file
---
# Need help with Layout? Other Questions?