Skip to main content

Posts

Showing posts from December, 2010

Android SDK: String Arrays and Controls like Spinners

Due to how the Android SDK and Java are setup it isn’t really a simple task to link up an array with a spinner control. I’ll go over some basics I just learned of the process. In this example I setup a setting control that will allow the user to select from a list of values. The spinner control will be initialized by the global setting value (from a black box object in this example), and a control listener will be defined that allows the user to change the global setting. To define a list of string values that can be loaded into android controls you would do something like this. You can add an arrays.xml file to your project (in the /res/values directory): <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="settinglist01"> <item>1</item> <item>2</item> <item>3</item> <item>4</item> <item>5</item> </string-a...