Android settings page

Source: Internet
Author: User

 

 
 

Android provides an interface for convenient settings, so you have to say a thumbs up. The designers of basic functions are taken into account, which greatly facilitates developers. If there are no special requirements for the UI, these interfaces can fully meet your needs. Let's talk less about them and use cases directly.

 

If it is just a simple setting, you can layout it in an XML file. In addition, the designer provides a wide range of controls for developers to use. I personally feel pretty. Note that it is best to place the XML of the layout file in the res XML folder (create one by yourself). An error occurred when I put the XML file in layout. The layout file is as follows:

 

<? XML version = "1.0" encoding = "UTF-8"?> <Preferencescreenxmlns: Android = "http://schemas.android.com/apk/res/android"> <preferencecategory Android: Title = "Q & A Settings"> <listpreference Android: Key = "listpreference" Android: title = "number of questions and answers displayed each time" Android: Summary = "" Android: defaultvalue = "20" Android: dialogtitle = "select the number of questions and answers to be displayed" Android: entries = "@ array/entries_list_preference" Android: entryvalues = "@ array/templates"/> </preferencecategory> <preferencecategory Android: Title = "Advanced Settings"> <checkboxpreference Android: key = "push" Android: Title = "Push accepted" Android: summaryon = "enable" Android: summaryoff = "Disable" Android: defaultvalue = "true"/> <checkboxpreference Android: key = "hdpi" Android: Title = "select high-resolution images" Android: summaryon = "high-resolution images" Android: summaryoff = "low-resolution images" Android: defaultvalue = "true"/> </preferencecategory> </preferencescreen>

If you want to use the set value, you can call it as follows:

 

 

 
Sharedpreferences SHP = preferencemanager. getdefasharsharedpreferences (this); Boolean apply_wifichecked = SHP. getboolean ("apply_wifi", false );

For more details about the controls on the settings page, see
Preference usage.

 

It is easy to learn, and it is inevitable that there will be omissions and errors. please correct me ~

 

Related Article

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.