Is there a way to make radio buttons do nothing when they are clicked? I am trying to make a Score Board and need a way to show the periods/halves/quarters ect. The radio buttons will be selected by the program to display periods/halves/quarters ect. Is this a good way to do it or is there a better way?
Check out the clickable attribute for Views
Defines whether this view reacts to click events.
Must be a boolean value, either "true" or "false".
http://developer.android.com/reference/android/view/View.html#attr_android:clickable
If the user doesn't ever need to click the radio buttons (ie if its always controlled by the program), why don't you just use images instead of radio buttons.
The benefits of using images for this are...
Images aren't clickable by default
It'll look nicer (you can make the Images look like a real scoreboard)
It doesn't rely on the default Android appearance (which is different for each phone)
Related
I am creating a panel showing many different kind of widgets such as button. The panel allows to zoom in and zoom out. It is required to show whole panel in the beginning. However, some users may touch more than one button when the panel is too small.
I want to handler the situation like chrome in Android. When the user touches more than one link, a pop up panel will be showing.
What library or APIs may I use?
Thanks!
You could place your Buttons in a FocusPanel implementing a ClickHandler to open your desired popup- thus when your user clicked between two buttons the click is registered and you can handle it.
Note, you will have to place a FlowPanel in that FocusPanel to place more than one button inside.
If you want to react on hover instead of on click, use HoverHandler instead.
I am designing my activity screen using eclipse but whenever I move an object e.g. a button it snaps around and I find it hard to position things where i want them.
Is there some setting I can change as as soon as I add a second button it snaps the other button to another position it is so annoying!
Also if I have an image button why can't i resize this, even with a normal button if i try to make it larger it just fits to the text and wont make the button bigger or it just flicks to a random place on the activity?
thanks
Probably you're trying to place components freely in the View but you're not considering the LayoutManager behavior. If you try to position your component in a LinearLayout, for example, the components will be placed following its rules, and these components will not stay where you drop them.
Try to understand better how the layouts works on Android. But for now, the AbsoluteLayout or RelativeLayout may be what you're looking for.
About the components size, you'll need to understand better how to use layout properties for these components. See the question How to size buttons for more information.
We have multiple checkboxes, as shown below:
We want the user to be able to select first checkbox for A,B,C, by him dragging over the checkboxes.
Is this possible in android?
Yes, you could do something like that. You'd have to first start a drag operation and drag a view. If you tried to do it with just your finger, it would be an exercise in gesture detection. But dragging a view would be simple.
Using this tutorial as a guide - http://developer.android.com/guide/topics/ui/drag-drop.html - you should be able to start a drag operation using a click listener on the view you want to drag. Then, as the dragged view enters the bounding boxes (you set up draglisteners on each) of a checkbox, you can set it to checked.
I am working on a Street Fighter Game. I need to have a character selection screen for the user. How can I do this character selection in Java libGDX? This is my image code. Can I do this using ImageClick event?
splashTexture1 = new Texture(Gdx.files.internal("assets/gui/Character1.PNG"));
splashTexture1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
splashSprite1 = new Sprite(splashTexture1);
splashSprite1.setX(100);
splashSprite1.setY(180);
My suggestiong is using scene2d for menu or HUD stuff.
Check this out : https://github.com/libgdx/libgdx/wiki/Scene2d
scene2d is a 2D scene graph for building applications and UIs using a hierarchy of actors:
buttons
labels
sliders
text buttons
scrollable views (lists)
tables
your custom widgets
group of actors
You can add ClickListener to an actor. (In your case the actor is a Button)
You can do it in two ways. I'd recommend using both.
Common stuff
You can list images of all characters in a screen. And let the user select any one using one of the following.
Click event
Each image will have a separate ClickListener (If you have problem regarding that, you should search 'How to add clicklisteners to libgdx actors).
On clicking any image, the variable storing selected character (for the rest of the game) will be set with the image that has been clicked. And the screen is changed.
Keyboard event
One of the image will have focus drawn around it. The user can move focus around to other character images using arrow keys. When user presses enter, the character that currently has focus gets selected and the screen is changed.
Hope this helps.
I would recomend to use the Table-Layout from libgdx for it. Add an ImageButton to a Table and add an ClickListener to the ImageButton. Add the same Texture as up and down Texture and you are done. Maybe change it later so the user see that he has clicked a figure.
The Table gives you the ability to arrange those Buttons in the way you like and it's structured. Moreover it is easy to create a dynamic view, that does have new ImageButton for every new Texture you add to a folder for example. Just create a ScrollPane with a the Table of "figures" (which are the ImageButton with an listener) and you can add a bunch of it and let the user scroll down and up to check which he likes.
I have an 8 by 8 linear Layout of buttons. I am making a small game similar to boggle, when i click a button i would like to be able to disable all buttons except for its surrounding buttons. This also involves the buttons on the edge. I basically need some help to start the logic of this game. any help is appreciated. i have so far thought about the structure of the program and how an 8 by 8 graph can possibly activate its neighbors, maybe if i can access the cell of each button the i can progress further?. Thank you.
Extend Button and give Buttonlisteners to each of the buttons according to who their neighbors are. Each button would have a buttonlistener tied to each of it's neighbors according to how you tie it together. If you don't want to use diagonal neighbors, a button would have a max of 5 buttonlisteners (if the button is listening to it's own button).)
This should be possible to accomplish using a simple Map:
Map<Button, List<Button>> surroundingButtons = new HashMap<Button, List<Button>>();
This Map is then, for each Button, populated with a list of it's surrounding Buttons. Unfortunately I have no clever idea how to do this easily at this hour.
I am thinking something like adding all buttons to a single list and pick them out using index of the current button +/- 8 modulo some index... Adding them manually might be just as easy.
When the Map is ready, it is very simple to disable the surrounding Buttons.
Button clickedButton; // not showing the onClickListener
for (Button sButton: surroundingButtons.get(clickedButton)) {
sButton.setEnabled(false);
}
Edit:
Read the question wrong but; disable all buttons except for its surrounding buttons
The idea still applies, just add all the buttons you wish to disable to the list associated with a button in the map.