i am fairly experienced at coding in java but i am just learning to build graphical user interfaces in android environment. I have searched alot for the answer to this question but i wonder if im not searching for the right thing?
I want to be able to choose between 2 radio buttons, and if the first of these radio buttons is chosen then a group of 2 more radio buttons should be chosen from. Its hard to explain exactly what i mean so i hope this helps.....
Choice One
1.a choice one a
1.b choice one b
Choice Two
So, if 'choice one' is picked then the user MUST pick from choices 1a OR 1b, whereas if the user picks 'choice two' then the sub options (1a and 1b) are not even available (greyed out i suppose).
I thought i could just nest one RadioGroup inside another, but it doesnt seem to work this way.
If anybody can help me here id be really grateful.
you could create a popup and fill the data on OnCLickListener and then display it.
Have you trying to use show() and hide() for radio button? maybe using a boolean for the parameter show() and hide()
Related
How can I make a grouping of RadioButton, of which at most one can be checked, but which allows all buttons to be unchecked? (I maintain that this has always been one of two common behaviours for groups of radio buttons.)
I haven't managed to get this to work with RadioGroup. It allows all the buttons to be unchecked on creation, but once one button is checked, there seems no way to get back to the original all-unchecked state. (Sure, in a parent's onRadioButtonClicked(), all the buttons can be unchecked -- but unfortunately by the time this is called, an unchecked button will already have been checked. So I think it would be necessary to keep a separate accounting of which buttons were previously checked, in order to use that.)
Two options have occurred to me.
One is to make my own "ReasonableRadioGroup", that allows both common behaviors. Seems a little extreme.
Another is to arrange for a long-click event on a checked button to uncheck the button -- but I don't think that would be obvious to a user.
But surely I'm just missing something!
How can I make a grouping of RadioButton, of which at most one can be checked, but which allows all buttons to be unchecked?
Sorry, there is no support for that in the RadioButton/RadioGroup classes in the Android SDK. It is possible that one of these libraries offers that, though it does not look promising.
But surely I'm just missing something!
No, sorry.
Did you try :
RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radiogroup);
radioGroup.clearCheck();
I have a pretty basic interface of a chromotagram viewer. In the menu I allow the user to reverse the viewer with a JCheckboxMenuItem. Functionally, it does exactly what its supposed to do. My interface allows for multiple chromatograms to be open at once. I will post a few example pictures as I get to my question.
Above I have one tab opened and have yet to reverse the chromatogram.
Above I have clicked the option and it worked.
Here is my issue. If I open another tab and move to it, the option is still checked even though I have yet to click that button. The easy way out would be just to make it a normal button but I just want to know if there is a way that each tabbed could keep track of if its been reversed yet. Would this require multiple instances of the button itself? If anybody has any suggestions, please let me know. Thank you.
if(centralPara.getNumOpen() > 1){
centralPanel = centralList.get(centralPara.getCurrentFrame());
JCheckBoxMenuItem reverseItem = centralPara.getReverseItem();
boolean reversed = centralPanel.getReversed();
reverseItem.setSelected(reversed);
}
in my tab change listener I check to see that we have atleast more than one tab open. if so get the frame we are currently viewing and the top level menu item. Force it be be selected if that the current view frame is selected, or else force it be unselected.
I'm developing a program in java for admin orders in a restaurant.
I have a screen like this.
Frame for admin orders.
I want to select any button from left and any button from right and clic in button "Agregar" later.
I'm thinking to do a method with a lot of conditions if and else if, for example.
if(buttonCombo1.isSelected() and buttonNumber1.isSelected()){
//Doing something
}else if(buttonCombo1.isSelected() and buttonNumber2.isSelected()){
//Doing something
}
I would have to do a lot of conditions, and I have no idea do otherwise.
If you can help me to find another way for do It, I would be grateful.
Note: I apologize for my bad english. I'm learning yet.
Thanks so much.
I don't remember if you can group simple buttons. But you can define a click function in each button to change the value of button in a Bollean Array (with lenght equals amount of button.)
In this case, you will have acess a boolean value directly for a index.
I am just learning AWT / Swift / JavaFx recently and I feel like I have learned a lot but have barely scratched the surface. There might be a much easier way to do this BUT, I am trying to make a GUI button in eclipse that calculates the distance between two objects that the user creates. Lets call them Robots for now. So, I have one button that allows the user to create the Robots and it stores them in a DefaultListModel (listModel) and displays them in a Jlist (list) below the buttons. When the user then clicks on a robot, another button becomes actice and allows them to calculate the distance between them (one of the parameters of the robots is their location on a grid). I have all that worked out but my problem is that I am trying to make it to where they have to select two different Robots. At first I thought I could let them select two Robots and then make the computeDistance button becomes active, but I am not really sure how to do that because the only way I can select more than one object in the JList is to cntrl click and I don't want the user to have to know that trick.
My next idea was to allow the user to have one Robot selected and then give them a popup window displaying the other Robots and have them select one. Via showOptionsDialog, I have discovered how to make a custom JOptionPane, so I thought, why not make them buttons (probably will look awful, but I don't know how to make anything other than JOptionPane.showXxx at this point (like I said, only skin deep so far). Have tried consulting the javadocs, but right now that is a LOTTT to take in and have read a decent amount, I thought.
Ok, sorry if this is long, but is there a way, using my DefaultListMethod to make custom buttons? I tried a bunch of ways by creating Object[] options = {list.elements()}; etc but that doesn't work. Any help would be much appreciated!
I have a program which prompts users to select a choice out of four options (from a group of RadioButtons).
Once the user has made a choice, he/she clicks a button and then receives a message. After closing the window, the user will go back to the first window and make a new selection if desired. What I want is for the radiobuttons to be totally clear.
So far I have implemented a method to actually unselect the radiobuttons and works well (clears the values of the variables), what it doesn't do is to remove the black spot from the previously selected radiobutton. In the other hand this same method works fine with unselecting and unchecking checkboxes.
Any tip to fix this little issue?
Here's my code:
public void clean() {
jRadioButton1.setSelected(false);
jRadioButton2.setSelected(false);
jRadioButton3.setSelected(false);
jRadioButton4.setSelected(false);
jCheckBox1.setSelected(false);
jCheckBox2.setSelected(false);
}
make them group of buttons and then buttonGroup1.clearSelection();