In this example, Light Theme and Default Theme are the same in code and resource. Both use layout of R. Layout. controls_1. The difference between Controls1.java and Controls2.java is only in the class name.
Controls_1.xml defines the following types of UI controls: Button, EditText, CheckBox, RadioButton, ToggleButton, Spinner, and TextView.
Here we mention RadioButton. RadioButton is a single-choice button. You need to define a group for a group of single-choice buttons. Only one single-choice button in the group can be selected. The group is defined as a RadioGroup, for example:
[Html]
<RadioGroup
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: orientation = "vertical">
<RadioButton android: id = "@ + id/radio1 ″
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/controls_javasradiobutton_1"/>
<RadioButton android: id = "@ + id/radio2 ″
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/controls_1_radiobutton_2"/>
</RadioGroup>
<RadioGroup
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: orientation = "vertical">
<RadioButton android: id = "@ + id/radio1 ″
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/controls_javasradiobutton_1"/>
<RadioButton android: id = "@ + id/radio2 ″
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/controls_1_radiobutton_2"/>
</RadioGroup>
In addition, CheckBox can define different styles. For example, this example uses a "star" shape:
<CheckBox android: id = "@ + id/star"
Style = "? Android: attr/starStyle"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/controls_sharestar"/>
In fact, most UI controls can customize the style.
This example and the following example use the "light color" style and the default style. This defines different styles for the Activity through AndroidMainifest. xml. For example:
<Activity android: name = ". view. Controls1 ″
Android: label = "Views/Controls/1. Light Theme"
Android: theme = "@ android: style/Theme. Light">
<Intent-filter>
<Action android: name = "android. intent. action. MAIN"/>
<Category android: name = "android. intent. category. SAMPLE_CODE"/>
</Intent-filter>
</Activity>
Author: mapdigit