Android : Editing values using alert dialog - android

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.

Related

Android ExpandableList Header with spinner

I'm developing an application and I am facing a problem using ExpandableListView. What I'm trying to do is, in GroupHeader, not only show the group name, but also an spinner with options. That's because I want to show the football second division games in the list but, also, give the option to choose the round, in case the user wants to check older/future games. SO far I have that
As you can see both, title and spinner, shows. Also you can see the arrow on the right which is supposed to expand the list. Problem is that, if I click, only spinner opens, group expand button doesn't. So, here is my question, how can I make both of them work depending on where you click (one or another)??? Is that possible?
Also I must say that if I only place the TextView with the group name works perfect. If I only place the spinner, the problem persists. So I'm guessing that's a focus problem.
Btw: grey areas are the layout backgrounds, so no, they are not hiding behind the button.
I found the solution, I just neede to add this line android:descendantFocusability="blocksDescendants" to the Main Layout of the xml where I define the GroupHeader elements.

Android:: Highlight a non-selected button

I am working on a game project.
I have 4 buttons on my screen. User has to select one of the 4. If user selects the correct one, it works fine. but if user selects incorrect one, I want to highlight the correct answer even though user didnt clicked it.
I have presentation due tomorrow. Can anybody point me to some example source or explain it here, as to how can I accomplish it.
You can set the correct buttons background color or image while clicking other buttons
Whenever user clicks on the incorrect button simply call :
correctButton.setPressed(true)
This will highlight the correct button as per your requirement.
you can do one thing..
Call Button.requestFocus() method to get the focus.
Create a custom selector for you Button's background. there
< item android:state_focused="true" android:drawable="#color/your_color" />

Displaying various options on a button click

I want to design a button such that when it is clicked, I get various options, from which I finally select one.
This is the same as using the concept as in text messages. For example: If we press and hold a, then we get various options for the various accents of 'a' in small buttons just above/below the button clicked.
How do I implement this in Android? Do I have to use context menus? How do I get the various options in small buttons? For that, will I have to use an OnTouchlistener?
Take a look at KeybordView.java from the 2.2_r1.1 release. That is the class that implements the keyboard handling. Pay special attention to the Handler around line 246 and the openPopupIfRequired method that displays the popup for the key if there is a long press.
Good luck.

UI Component for Launching ListView with onActivityResult

I have this SearchMenuActivity that has a bunch of options the user can select. Two of the options fires an intent to a ListView where the user can select a value and then it reports back to the SearchMenuActivity. I also have another option like this except it allows the user to select multiply options. The problem that I am having is choosing a UI component that will launch the ListActivity and hold the results when it reports back via onActivityResult. I have come up with a couple solutions here they are ...
Solution 1
Use a button which default text is "Choose item a". This will launch the ListView and then when the user selects an item the text of the button will become the selection.
Solution 2
Use a spinner. The problem with this is that spinners do not support multi selection items. It would also complicate things because the items in the list view are being pulled from a server backend and displaying a loading message on top of the spinner would look ugly.
Solution 3
Have a clickable textview which default text is "Click here to select item". This will launch the ListView and then when the user selects an item the text of the textview will become the selection.
Right now I am implemented solution 3. The "Click here to select item" seems intrusive. Anyone have any ideas as to what is the best method to solve this problem?
Option 3 is the best
However it is not very nice for changing his choice. I think you must add a small icon to the right of the TextView that allows the user to re-select.

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