Android DatePicker Dialog (DatePickerDialog)
The Properties window will only show values that are explicitly set for the selected widget; it will not show values that are inherited from the theme.
Resource Qualifier Options can be accessed by clicking the down triangle icon to the right of the Device Configuration options:
In this example, it is chosen fr (French) for the language and BE (Belgium) for the regional dialect of French. Note that the Region field is optional because many languages can be specified without regard for specific regions.
RadioGroup and RadioButton
ToggleButton and Switch
Creating a Grid Layout
You should be careful about over-using the LinearLayout. If you begin nesting multiple LinearLayouts, you may want to consider using a RelativeLayout instead.
For those working on cross-platform applications with Xamarin.iOS, the ListView control is structurally similar to the iOS UITableView (and the Android Adapter is similar to the UITableViewSource).
In Android development, any time we want to show a vertical list of scrollable items we will use a ListView which has data populated using an Adapter. The simplest adapter to use is called an ArrayAdapter because the adapter converts an ArrayList of objects into View items loaded into the ListView container.
Instead, as the user scroll through the list, items that leave the screen are kept in memory for later use and then every new row that enters the screen reuses an older row kept around in memory. In this way, even for a list of 1000 items, only ~7 item view rows are ever instantiated or held in memory. Here is a visual overview of recycling:
getView() is the method that returns the actual view used as a row within the ListView at a particular position. Another method used is getItem() which is already present in the ArrayAdapter Class and its task is to simply get the data item associated with the specified position in the data set which is associated with that ArrayAdapter.
To improve performance, we should modify the custom adapter by applying the ViewHolder pattern which speeds up the population of the ListView considerably by caching view lookups for smoother, faster item loading:
The GetView method should follow this pattern to re-use row views:
There are twelve built-in Views that can be referenced usingAndroid.Resource.Layout:
Customizing a ListView’s Appearance
Creating Custom Row Layouts
The Android XML markup to declare this layout is described in /Resources/Layout/CustomView.axml:
The implementation of the custom adapter example is in HomeScreenAdapter.cs. The key method is GetView where it loads the custom AXML using the resource ID Resource.Layout.CustomView, and then sets properties on each of the controls in the view before returning it. The complete adapter class is shown:
Referencing the Custom ListView in the Activity
Customizing the Row Selector Color
Creating an SQLite Database
Creating the Cursor
Implementing the CursorAdapter
Under normal conditions, rotating a device will cause a ListView and Adapter to be re-created and (unless you have written code in OnPause and OnResume) the scroll position and row selection states will be lost.
The following attribute would prevent an activity from being destroyed and recreated as a result of configuration changes:
The Activity should then override OnConfigurationChanged to respond to those changes appropriately. For more details on how to handle configuration changes see the documentation.
The following example configures the application MyApp to use the light theme:
RecyclerView is an Android widget that displays a collection of items in a list or a grid, enabling the user to scroll through the collection.
How View Recycling Works
The View Holder
Calling NotifyItemChanged is significantly more efficient than calling NotifyDataSetChanged.