Unit 2
Unit 2
Essentials
UNIT-2
View class
• Button
public class Button extends TextView
• A user interface element the user can tap or click to
perform an action.
• To display a button in an activity, add a button to the
activity's layout XML file:
• <Button android:id="@+id/button_id"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/self_destruct" />
Layout resource
• A layout resource defines the architecture for the UI
in an Activity or a component of a UI.
• <ViewGroup>A container for other View elements.
• There are many different kinds of ViewGroup
objects and each one lets you specify the layout of
the child elements in different ways. Different kinds
of ViewGroup objects include LinearLayout,
RelativeLayout, and FrameLayout.
• <View>
• An individual UI component, generally referred
to as a "widget". Different kinds of View objects
include TextView, Button, and CheckBox.
• <requestFocus>
• Any element representing a View object can
include this empty element, which gives its
parent initial focus on the screen. You can have
only one of these elements per file.
• <include>
• Includes a layout file into this layout.
Write and View Logs with Logcat
• The Logcat window in Android Studio displays system
messages, such as when a garbage collection occurs, and
messages that you added to your app with the Log class. It
displays messages in real time and keeps a history so you
can view older messages.
• When an app throws an exception, logcat shows a message
followed by the associated stack trace containing links to
the line of code.
• To display just the information of interest, you can create
filters, modify how much information is displayed in
messages, set priority levels, display messages produced by
app code only, and search the log. By default, logcat shows
the log output related to the most recently run app only.
View your app logs
• Notifications Overview
• A notification is a message that Android
displays outside your app's UI to provide the
user with reminders, communication from
other people, or other timely information
from your app. Users can tap the notification
to open your app or take an action directly
from the notification.
User Interface Screen elements
3 Table Layout TableLayout is a view that groups views into rows and
columns.