ImageButton, RadioGroup, CheckBox, ToggleButton in android

Source: Internet
Author: User

Activity_main.xml Configuration:

[Html]
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Xmlns: tools = "http://schemas.android.com/tools"
Android: id = "@ + id/LinearLayout1"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: orientation = "vertical">
 
<TextView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/hello_world"
Tools: context = ". MainActivity"/>
<! -- Image button -->
<ImageButton
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: src = "@ drawable/home"
Android: contentDescription = "@ string/imagetext"
/>
<! -- Add images and text in the button -->
<Button
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/textbtn"
Android: drawableRight = "@ drawable/home" <! -- Home here is an image in the drawable folder under the res directory. The specific drawable can be used. -->
/>
<! -- Radio group, single choice button -->
<RadioGroup
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
>
<RadioButton
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/nan"
/>
<RadioButton
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: text = "@ string/nv"
/>
</RadioGroup>
<! -- Switch Status button -->
<ToggleButton
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: textOff = "open"
Android: textOn = "disabled"
/>
<! -- Checkbox multi-choice button -->
<CheckBox
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "1. Jiangxi"
/>

<CheckBox
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "2. Fujian"
/>

<CheckBox
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "1. Zhejiang"
/>
</LinearLayout>
Strings. xml mainly configures text writing information:

[Html]
<Resources>
<String name = "app_name"> ImageButton </string>
<String name = "hello_world"> image button </string>
<String name = "menu_settings"> Settings </string>
<String name = "title_activity_main"> MainActivity </string>
<String name = "imagetext"> This is an image button </string>
<String name = "textbtn"> button text </string>
<String name = "nan"> male </string>
<String name = "nv"> female </string>
</Resources>

 

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.