6
Android Development: Basic Widgets Richard S. Stansbury 2015

Android Development: Basic Widgets Richard S. Stansbury 2015

Embed Size (px)

Citation preview

Page 1: Android Development: Basic Widgets Richard S. Stansbury 2015

Android Development:Basic Widgets

Richard S. Stansbury2015

Page 2: Android Development: Basic Widgets Richard S. Stansbury 2015

Widgets

• Widgets are display elements that compose the layout of the Android application

• Common examples:– Labels– Form elements– Images– Maps– etc.

Page 3: Android Development: Basic Widgets Richard S. Stansbury 2015

Widget Configuration Elements

• ID– @+id/<id_value> for first declaration– @id/<id_value> for future declarations– in java you can use:

findViewById(R.id.<id_value>)• Dimensions– layout_width, layout_height

• Possible values: a dimension, wrap_content, match_parent• E.g. <TextView

android:id = “@+id/aLabel”android:layout_width=“wrap_content”android:layout_height=“wrap_content”

Page 4: Android Development: Basic Widgets Richard S. Stansbury 2015

Widget: TextView

• Displays a text label– Attributes:• android:typeface -

– See http://developer.android.com/reference/android/graphics/Typeface.html

• android:textStyle – bold, italic, bold_italic• android:textColor – RGB or ARGB• android:text = “@string/<string_id>”

• Let’s look at some real examples in Eclipse…

Page 5: Android Development: Basic Widgets Richard S. Stansbury 2015

Widget:Button

• Produces a clickable element• Common attributes:– Many of the same as TextView– android:onclick=“<function_name>”

• States click handler method• Useful for many simple layouts• Not useful for fragments

• Look at example in Eclipse…• Refer to the build task that you had last Friday…

Page 6: Android Development: Basic Widgets Richard S. Stansbury 2015

Widget:EditText

• Permits text entry• http://developer.android.com/reference/andr

oid/widget/EditText.html

• Attributes– Many same as TextView– android:inputType– android:hint– android:autotext