Android ApiDemos example resolution (107): Views-& gt; Controls-& gt; 1.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.