🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

05 Android User Control.pptx

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Transcript

ANDROID USER CONTROL TextView CheckBox EditText ProgressB ar Button Spinner ImageButto TimePicker n ToggleButto DatePicker n RadioButton SeekBar RadioGroup AlertDialog RatingBar Switch Introduction Thi...

ANDROID USER CONTROL TextView CheckBox EditText ProgressB ar Button Spinner ImageButto TimePicker n ToggleButto DatePicker n RadioButton SeekBar RadioGroup AlertDialog RatingBar Switch Introduction This lesson introduces on how to developing Android Application using different user input controls. Objectives At the end of this lesson, the student will be able to: Recognize and apply the rules in developing Android Application that using different user input controls. Users expect to interact with apps Clicking, pressing, talking, typing, and listening Using user input controls such buttons, menus, keyboards, text boxes, and a microphone Navigating between activities Users expect to interact with apps Important to be obvious, easy, and consistent: Think about how users will use your app Minimize steps Use UI elements that are easy to access, understand, use Follow Android best practices Meet user's expectations Ways to get input from the user Free form Constrained ○ Text and voice input choices ○ Pickers Actions ○ Checkboxes ○ Buttons ○ Radio buttons ○ Contextual menus ○ Toggle buttons ○ Gestures ○ Spinners ○ Dialogs Examples of user input controls 1.Button 2.Text field 3.Seek bar 4.Checkboxes 5.Radio buttons 6.Toggle 7.Spinner Alert dialog, date picker, time picker View is base class for input controls The View class is the basic building block for all UI components, including input controls View is the base class for classes that provide interactive UI components View provides basic interaction through android:onClick Focus The view that receives user input has "Focus" Only one view can have focus Focus makes it unambiguous which view gets the input Focus is assigned by ○ User tapping a view ○ App guiding the user from one text input control to the next using the Return, Tab, or arrow keys ○ Calling requestFocus() on any view that is focusable Clickable versus focusable Clickable—View can respond to being clicked or tapped Focusable—View can gain focus to accept input Input controls such as keyboards send input to the view that has focus Which View gets focus next? Topmost view under the touch After user submits input, focus moves to nearest neighbor—priority is left to right, top to bottom Focus can change when user interacts with a directional control Guiding users Visually indicate which view has focus so users knows where their input goes Visually indicate which views can have focus helps users navigate through flow Must be predictable and logical—no surprises! Guiding focus Arrange input controls in a layout from left to right and top to bottom in the order you want focus assigned Place input controls inside a view group in your layout Set focus explicitly Use methods of the View class to set focus setFocusable() sets whether a view can have focus requestFocus() gives focus to a specific view setOnFocusChangeListener() sets listener for when view gains or loses focus onFocusChanged() called when focus on a view changes EditText EditText class Multiple lines of input Characters, numbers, and symbols Spelling correction Tapping the Return (Enter) key starts a new line Customizable "Action" key Buttons View that responds to clicking or pressing Usually text or visuals indicate what will happen when it is pressed State: normal, focused, disabled, pressed, on/off Visuals: raised, flat, clipart, images, text ImageButton A type of button in Android that displays an image instead of text and shows a drawable resource (an image) that serves as its content Primarily designed for cases where an image conveys the action more effectively than text CheckBox User can select any number of choices Checking one box does not uncheck another Users expect checkboxes in a vertical list Commonly used with a submit button Every checkbox is a view and can have an onClick handler RadioButton User can select one of a number of choices Put radio buttons in a RadioGroup Checking one unchecks another Put radio buttons in a vertical list or horizontally if labels are short Every radio button can have an onClick handler Commonly used with a submit button for the RadioGroup ToggleButton and Switch User can switch between 2 exclusive states (on/off) Used to toggle between two options (e.g., enabling/disabling a feature). Used for enabling/disabling settings or features in an app. Toggle buttons Switches Spinner Quick way to select value from a set Drop-down list shows all values, user can select only one Spinners scroll automatically if necessary Use the Spinner class. Require an Adapter for ArrayList Define array of spinner choices In arrays.xml resource file Home Work Mobile Other What is an adapter? An adapter is like a bridge, or intermediary, between two incompatible interfaces For example, a memory card reader acts as an adapter between the memory card and a laptop Memory Card Layout Laptop Card Reader Computer (Array of (Adapte (Spinner Choices) r) View) Dialogs Dialog appears on top, interrupting the flow of activity Require user action to dismiss AlertDial TimePickerDial DatePickerDialo og og g AlertDialog An AlertDialog in Android is a modal dialog that can display a message and optionally offer actions (buttons) to the user. It is often used to provide information, seek confirmation, or prompt the user to make a decision. The dialog appears on top of the current activity and requires interaction before the user can return to the underlying activity. AlertDialog AlertDialog can show: 1.Title (optional) 2.Content area 3.Action buttons Action buttons in AlertDialog alertDialog.setPositiveButton() alertDialog.setNeutralButton() alertDialog.setNegativeButton() Action buttons in AlertDialog Positive button – confirming or proceeding with an action. Negative button – canceling or declining an action. Neutral button – for actions that aren't clear positive or negative, such as "Remind me later". DatePickerDialog A DatePickerDialog is a modal dialog that allows the user to pick a date (day, month, and year). It provides a calendar-like interface for users to select a date. This is commonly used in forms or apps where users need to input a date, such as in booking, scheduling, or event apps. TimePickerDialog A TimePickerDialog is a modal dialog that lets the user select a time (hour and minute) either in 12-hour or 24-hour format, depending on the configuration. It is useful for apps that need time input, such as alarm, reminder, or scheduling apps.

Tags

user input Android development application design software engineering
Use Quizgecko on...
Browser
Browser