Unit 4
Unit 4
XML Attributes
UNIT 04
1. android:divider Drawable or color to draw xml
between list items. <ImageView
android:layout_width="wrap_content"
2. android:dividerHeight Height of the divider. android:layout_height="wrap_content"
3. android:entries Reference to an array resource android:src="@drawable/my_image"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" Provides a widget for selecting a date.
android:text="This is some scrollable text
content." /> xml
<DatePicker
</LinearLayout> android:id="@+id/date_picker"
</ScrollView> android:layout_width="wrap_content"
android:layout_height="wrap_content" />
XML Attributes
1. android:fillViewport Defines whether the To listen that user has selected a date
scrollview should stretch its content to fill the java
viewport. DatePicker datePicker = (DatePicker)
4.3 findViewById(R.id.date_picker);
datePicker.setOnDateChangedListener((view, year,
TimePicker monthOfYear, dayOfMonth) -> {
// listen
});
XML attributes
1. android:maxDate The maximal date
shown by this calendar view in mm/dd/yyyy
A widget for selecting the time of day, in either 24- format.
hour or AM/PM mode. 2. android:minDate The minimal date
xml shown by this calendar view in mm/dd/yyyy
<TimePicker format.
android:id="@+id/time_picker" 3. android:datePickerMode Defines the
android:layout_width="wrap_content"
android:layout_height="wrap_content" look of the widget.
android:timePickerMode="clock" />
To get time after user has changed time * For Showing DatePicker & TimePicker use dialogs.
java
timePicker.setOnTimeChangedListener(
(view, hourOfDay, minute)->{
// Do something with the selected hourOfDay
and minute
});
XML attributes
1. android:timePickerMode: (optional) Sets the
mode for displaying time.
a. clock (default): Displays time using a
clock face with dials for hours and
minutes.
b. spinner: Displays time using separate
spinners for hours and minutes.