Is there "FloatingToggleButton" or something like that in Android? - android

I want to use FloatingActionButton for "like" action, but there should be two states for this, liked and unliked. So ToggleButton is suitable for this, but is there anything that combines the feature of these two kinds of button?

You can use the checkbox with checked and unchecked images. so that you can able to manage it for like and like within same button action. this link will help you to get the checkbox selector which use icons for different state.

Basically this depend on your scenario,for eg if want to show like dislike only then use toggle button only and if want to perform some action then use floating action button with all the action..
Like for particular page change background black white,increase text size etc..All depends on scenario..And always try to choose best not to fail at any stage...For anything pls ask

Related

How to create a field whose text changes in android

I am just starting with android. This is what i want to make:
Now when you click on From, a new screen would open where you can select places and once you select you will get back to this screen where instead of "Bangalore" it would be the place you selected.
What kind of a field is this ? Text field ?
Also if i want to add any effect like when you click on it its color changes, how would i go about it ? Any tutorials or documentation i can check out for this.
Yes, you will probably want to use TextView.
You can change the text it displays by using SetText(), and you can change the text color by using SetTextColor().
You need a TextView to display text, but if you want to display an image, text and be able to interact with that, then Button or ImageButton is what you need.
Your question is too broad, so I encourage you to start doing some tutorials. To implement all that stuff you'll need to learn about layouts and activities, dialogs, listviews, ... Basic Android, but it needs a minimum of experience.

how can I add a spinner in a category preference

I need to add a spinner in my PreferenceCategory with a text on its right is there a way to do that? plus when I create a checkboxpreference the text is on the left how can I make the text appear on the right?
thanks.
If you want to use these built in controls you have to use them the way they are designed. Its also good because it fits the android design that users expect.
If you need to do something different, just make your own preference screen. Its just a list view with click handlers, not too hard to make on your own. Then you get the styling you want.

Android : Editing values using alert dialog

In my application I currently have an xml layout that is re-used to enter information 6 times (these are turns in a game). This works fine. At the end of the round I present a screen that has a summary of each turn. I want to implement a button beside each turn to "edit" that turn. There are 3 possible things that can be edited. Ideally an alert dialog or something like a "popup" would be idea for this.
Would I be best off to have 3 buttons per "turn" for editing or is there a way to do this with a popup?
Thanks for your input on this matter.
You could list each turn and it's information with a single edit button next to each. When the edit button is pressed, create a new activity (intent) that prompts for all three pieces of data.
You have several options (and probably more I'm not thinking about). If these are in a ListView (or even if not) you could use a ContextMenu. You could have options in here to change the selected item or others. This would show a popup when the user long clicks the item
A PopupMenu can give you a similar effect that can pop up a list of options when the user clicks on a Button. Note that this requires API >= 11
You also could use an AlertDialog, as you mentioned. But just from what little I know about what you are trying to do I'm not sure this is what you would want.
Again, I don't know enough details about what you have or want but I would say that one of the first two options would suit you best. As far as one Button or multiple Buttons, that depends on the layout that will work best for your app, I suppose. You certainly could have one "Edit" Button which uses something like a PopupMenu and allows the user to choose what to edit. I hope this helped a little.

Show selected button

I have a group of buttons which enable user to select certain views on the touch screen.
I want to have the user know which view is active by showing a halo (or any other style) around the button. I mean when the button is clicked it's normal state is changed to different style but it is still normal.
I googled and checked in stackoverflow, that it is not possible to change the style at runtime.
How can I achieve the desired effect?
I have some silly ideas which I won't implement unless as last resort, like making two buttons at same positions and changing their visibility.
Or I can put each button in it's own linear layout and then set the background color of each of them, if it is possible.
Or some ImageButton manipulation maybe.
I have already overridden the default style for button for normal pressed states.
And setting focus(when in focusInTouchMode) causes problem, so that's a NO (already tried that).
Even if style can't be changed, please advise some tip to achieve the effect, it's not necessary to do it the style way. I just want o let the user know which view is selected through buttons.
use state list and set its focussed state drawable as the button with a ring around it and then at runtime say button.requestFocus(). see here for more on state list...
Go for selector xml background for each button. Best Resort
Check this link
How to set image button backgroundimage for different state?
Hpoe this helps
or you can use like ::
Button button;
public void onClick(View v)
{
button.button.setBackgroundColor(**color**);
button.setBackgroundResource(**res**)
}

popup windows in android?

Pretty new to android so excuse me if this is a really obvious question.
Say my application has a bunch of TextViews, each one showing the attributes of a certain product (name, price, etc). I have a button next to each of these TextViews labeled "modify".
How do I make it so that when I press the modify button next to a certain attribute, a popup window with a space to enter text into comes up so that the user can enter text into this box and then have the actual attribute listing on the original page change? Actually I just need a push in the right direction with creating this popup text field... not sure if there is already some built in functionality for this or if not, what would be the best way to create this kind of thing.
Thanks.
Why not have the modify button set TextEdit.setEnabled(true); and then change focus with TextEdit.setFocus? Note that both of these are inherited from view
If you really want a dialog you might want to looking into the AlertDialog.Builder. I know you can use it with buttons and radio buttons, but I'm not sure you can get it to work with a TextView.
Use a code like this for the input popup: Android dialog input text
In the positive button handler, set your edittext content programmatically like this:
myEditText.setText(value).
As simple as that. The only difference with a standard GUI framework is that you don't retrieve the value as a result of the popup function. Instead, you must provide an action handler.

Categories

Resources