Android: Rendering RadioButton as an ordinary Button - android

Is there a way to create a RadioGroup consisting of a few RadioButtons, such that the look of each RadioButton is like an ordinary Button rather than the default look (a checked circle beside some text)?
Is it necessary to fall back on a LinearLayout of Buttons and manually change the background of the buttons when handling button presses in a listener?
Edit: To be concrete, say we have two RadioButtons, foo and bar. When one is pressed, the string is displayed in boldface. The small circles that are normally next to each RadioButton is omitted. Is it necessary to manually make the change from and to boldface?

You can always put a custom look for you radio buttons, such as adding android:background=#drawable... and then setting a custom image for checked and unchecked state.

Related

How to use radio button to change another Button?

How to use radio buttons to decide which button any two buttons should appear where both buttons perform different task? In other words, if i change the radio button a button (normal button) should disappear and another button should take its place which performs another task.
You can use relative layout and place one button on top of the other, then set one of them visibility to "Gone" or "Invisible" when your activity starts or directly in the xml file. Finally add a onCheckedChangelistener to your radio button and change the visibility of the buttons as you need.

Android Development make Buttons work like RadioButtons

I have 11 Buttons with Background Images and if i switch to the actual RadioButton the circle thing on the RadioButton would show up and make my Background drawables ugly is there a way to make buttons work like RadioButtons?
I'm assuming the image changes when you click on the button to show it is selected. In that case, in your onclicklistener for the first button, you could change the image of that button to show it is selected, and also change the images of the other buttons to the unselected image. Do the same for each button.

Multiple EditText values in Button

Is it possible to combine 4 strings into one Button with proper separation/styling between them?
For example,
http://i.imgur.com/swJzQ.png
Currently I have the values in a tablerow but I would like for it to act like a button.
Thanks.
EDIT: Figured it out.
Within the onclicklistener I added:
tr1.setBackgroundResource(drawable.list_selector_background);
where tr1 is my tablerow. (you will need to make the tablerow final for it to work).
I'm currently looking into a different list_selector color but this does the trick.
In one button, I don't think so but you can put your 4 String in a layout,set a selector in background and add a clickListener on your layout.
You can create an image that has the four strings correctly spaced, then put it in your drawables folder and apply it as a background for a button.
Or you can create a RelativeLayout with four buttons inside of it. Each of the four buttons has the text you want, and make them all go to the same place. You can space them evenly to where there is no empty room left between them.
You could make it a Custom ListView, it wouldn't be a button but you can still have an OnItemClickListener

Android: Problem with 'on Click' effect

I have a problem that would be hard to explain. In my listview the list item's have imageviews. I would like to have an 'on click' or 'on pressed' effect that changes the background of the whole list row, and also the imageviews. I tried 2 approaches:
a) defining the xml selector state list for the row's layout
b) setting an onClickListener in java code
Option a) is no good because I can only change the items background and can't change the imageviews (defining a state list for imageviews is no good because it only works when the exact object is touched. and I want the effect whenever any location of the row is touched)
option b) works almost correct - i set the background resource for the layout of the list item and also change the image resource for imageviews. however, afterwards they stay like that. I am now wondering how can I change back to normal to achieve the effect of a short 'blink' in the java code. Just like with a button - you press it and it blinks orange for a split of a second.
PS: the permanent change of resources is important, because on press I open another activity with item's details and when I press the 'back button' the row looks like permanently selected.
I found a solution with using the OnTouchListener instead of onClickListener.

Any better approach for layout design?

just wondering if anyone else has a better suggestion that what I'm coming up with.
The issue is to do with a TabLayout, 5 Tabs all using a single Activity. Each Tab layout contains quite a few fields so the main parent on each tab is a ScrollView.
What I currently have is a 'Save' & 'Cancel' button sitting outside the scrollviews so theyre always visible and there for the user regardless which tab they're on. The problem is that since I'm using Tabs and always have these buttons visible when they are editing and the IME is displayed, they'res barely any of the form visible.
So I think the best thing for me to do is to probably show the buttons at the end of each scrollview. What I don't like about this is as I have 5 tabs, it will mean I have to declare 5 sets of the buttons, and of course define them and bind them in the Activity.. which seems rather messy and inefficient.
So if anyone has any better ideas I sure would love to hear them :-)
Thanks
Rgds,
Dave
Some of the options you got is
Try to put a title bar, and move the save and cancel buttons there (Small image buttons).
Save can be moved to the menu too (not recommended).
Auto Save functionality can also help, depends on how useful is it to you.
Try to use custom images for tabs, and make it take less space.
else, remove the save and cancel buttons, after the user makes any modifications, and presses back, prompt him to save the unsaved changes.
You could make it that when you're in tab X, the tab button for tab X now becomes X(save), so if they click again on the tab button in the same tab, it saves. That saves you five buttons, potentially...
Define programmatically the buttons inside a LinearLayout and add them to each ScrollView with addView. The code of the buttons should check in what tab are we at that moment, and act accordingly.
Then you'll have the same two buttons arranged in the same way in all your ScrollViews.
Or, if you dislike doing it programmatically, do a layout for the buttons and use View.inflate of that layout, and add them via addView to the ScrollView.

Categories

Resources