views:

982

answers:

4

Currently working on a mobile app in J2ME and have questions with radio button answer options. Any suggestion on how to make it so that no default answer is selected? We've tried:

cg8.setSelectedIndex( -1, true ); But get an out of bounds exception error

and

setSelectedFlags( boolean[] ) with all false, but also get another error.

To get around this, we've also tried creating an invisible radio button and have that set as selected, but couldn't find a way to make an invisible radio button either.

Any thoughts or suggestions would be great appreciated!!

+2  A: 

It sounds to me like the platform is enforcing an appropriate convention, although I must apologise for taking a purist standpoint here; this won't really answer your question.

Radio buttons are used when there are multiple exclusive choices, of which one must be made; it makes a certain amount of sense, therefore, for the user interface to ensure that something is always selected. Ideally, the initial selection in a radio group should always be a safe and sensible default.

Rob
That makes complete sense, thank you.The business rules for this particular app is that none of the answers are pre-selected so as to not sway the user to choose one answer over another. Any thoughts on getting around that issue?
Perhaps have the first option as something like "please choose from the options below"? It's also bad from a purist perspective but your business requirements deviate from techie best practices. (And of course have both client-side and server-side validation to ensure they pick a "real" option).
Andrzej Doyle
A: 

As far as I know, the only way to not have any radio button pre-selected is to draw the control yourself. Re-implement a radio button list using a Canvas or a CustomItem.

It's a lot of work, unfortunately.

You should look into LWUIT as it may have an intermediary solution.

QuickRecipesOnSymbianOS
A: 

"Radio buttons are used when there are multiple exclusive choices, of which one must be made"

I disagree. Radio buttons simply allow one selection max. Take multiple choice tests like the SAT, you don't have to answer every question and sometimes it's best not to.

The existence of the SAT does not directly influence the specification of radio buttons in any way. All one can really conclude from your statement is that it would be inappropriate to use radio buttons to implement SAT questions.
Andrzej Doyle
A: 

@QUICKRecipes: I disagree - to allow one selection max is the job of the "Select" input. Convention brought around by browsers has changed the interpretation of radio input to one that can accept a none-answer. RFC1866 states:

At all times, exactly one of the radio buttons in a set is checked. If none of the elements of a set of radio buttons specifies `CHECKED', then the user agent must check the first radio button of the set initially.

The whole nature of the original "real-life" radio button is that you one button must always be pressed. You canot "listen" to "null" radio station, and you cannot listen to multiple radio stations.

Phil