Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old December 10th, 2009, 04:19 AM   #1 (permalink)
New Member
 
Join Date: Dec 2009
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create combobox without XML

How can I create a combobox programmatically without using XML?

IORI999 is offline  
Reply With Quote
Sponsors
Old December 13th, 2009, 01:17 PM   #2 (permalink)
New Member
 
Join Date: Dec 2009
Posts: 8
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Check out the Spinner class.

Code:
//spinner view
RelativeLayout.LayoutParams spinnerParams = 
    new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
spinnerParams.setMargins(1, 1, 1, 1);
spinnerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

spinnerValueView = new Spinner(context);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, optionsStr);          
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);                     
spinnerValueView.setAdapter(adapter);  
spinnerValueView.setSelection(selected, true);
spinnerValueView.setOnItemSelectedListener(this);
nameValueLayout.addView(spinnerValueView, spinnerParams);
Jeff
trackaroo is offline  
Last edited by trackaroo; December 13th, 2009 at 01:17 PM.
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
General Please create tab for S7 vapor311 Huawei Ideos S7 0 December 9th, 2010 12:14 AM
How do you create a Nandroid? HeXiiK Droid X - All Things Root 13 October 19th, 2010 10:07 PM
Create PDF? hurley710 HTC Droid Eris 1 October 1st, 2010 03:36 PM
Programmatically set typeface and textsize of Spinner / ComboBox mobiforms Application Development 0 September 14th, 2009 04:39 PM
i want to create an app! hobdiddy Android Applications 0 November 12th, 2008 01:09 AM



All times are GMT -5. The time now is 11:38 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo