Custom View

Custom control states in library projects

SDK Version: 
M3

This is a tutorial about adding states to custom controls in library projects. So first, how to create and reference library projects: Setting up library projects, Referencing library projects.

Now that the project is setup you can start creating custom controls and states for them. This will all be inside the library project. Firstly you need to create an attributes xml file in values/attrs.xml (the name has to be attrs.xml) and adding the state:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>    
  3.     <declare-styleable name="customTextViewState";>
  4.         <attr name="state_marked" format="boolean" />
  5.     </declare-styleable>    
  6. </resources>

Custom views in a PreferenceActivity

SDK Version: 
M3

Let's take another look at PreferenceAcitivites, and how we can use other views, than the basic PreferenceActivity views.

Custom View - HorizontalSlider

SDK Version: 
M5

In this tutorial we'll create a custom View called HorizontalSlider based on ProgressBar. This slider will allow the user to move the slider back and forth on the screen and get notified when this happens.

Syndicate content