Graphical User Interfaces

95
Graphical User Interfaces

Transcript of Graphical User Interfaces

Graphical User Interfaces

Common Layouts

Basic XML Layouts - Containers

Four techniques for handling event

• Use current class as the listener

• Define a new class and use it as the listener

• Use an anonymous class as the listener

• Use an inner anonymous class as the listener

Use current class as the listener

Define a new class and use it as the listener

Use an anonymous class as the listener

Use an inner anonymous class as the listener

When to use each technique?

• In most cases, you can use any of these four techniques for your app. So, which technique should you use? In most cases, that’s largely a matter of personal preference.

• However, if you need to wire the exact same event handler to multiple widgets, you should reduce code duplication by using one of the first three techniques.

• In general, I recommend using the technique that result in the most readable and maintainable code.

• I also recommend using the same technique throughout an app whenever possible for the sake of consistency.