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.
Widget Configuration Elements ID for first declaration for future declarations – in java you can use: findViewById(R.id. ) Dimensions – layout_width, layout_height Possible values: a dimension, wrap_content, match_parent E.g. <TextView android:id = android:layout_width=“wrap_content” android:layout_height=“wrap_content”
Widget: TextView Displays a text label – Attributes: android:typeface - – See peface.html peface.html android:textStyle – bold, italic, bold_italic android:textColor – RGB or ARGB android:text = ” Let’s look at some real examples in Eclipse…
Widget:Button Produces a clickable element Common attributes: – Many of the same as TextView – android:onclick=“ ” 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…
Widget:EditText Permits text entry oid/widget/EditText.html oid/widget/EditText.html Attributes – Many same as TextView – android:inputType – android:hint – android:autotext