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.
Related
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.
I am implementing a text editor (not using TextView or EditText components) and when a word is misspelled I would like to bring up a popup similar to what TextViews have after you tap on the word. Is this UI the TextView brings up available in the android framework to use or will I have to create my own custom UI for this?
I can't seem to find anything after searching through the documentation. All I can find is a spell checker framework which just tells you if a word is misspelled and gives you an array of suggestions. Is there something in the input method service that might provide this UI?
Edit: I also need the "Add To Dictionary" option in the context menu so the user can add new words to the user dictionary. Similar to how TextView does it.
I haven't implemented it myself yet, but it looks like using a ListPopupWindow will work. It also interacts with IME if you wish and anchors itself to a parent view.
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.
How do I add a "edittext" that when you type in a specific word such as "apple" it will make a new xml page pop up. But if the user types in a different word besides "apple" it will make a different xml page pop up.
What I'm trying to accomplish is somethings similar to a logo quiz game where when you type in the right word, a new thing pops up.
I have absolutely no idea how to do it. if u could show me a video on how to do it, that would be very helpful thanks! :)
You should use a TextWatcher to watch for changes and do whatever you want on afterTextChanged().
I was trying to make my UI as neat as possible,
The user should enter some values into a circuit diagram,so I was trying to make the user click the resistor for example, then, a pop-up window appear with an EditText field in it for the user to enter the value of the resistor.
So far I was able to do that by using two separate setContentView()s, one for the circuit diagram and the other holds the EditText field, but I want the layout with the circuit Diagram to be visible in the background while the pop-up is the one in focus.
something like this (random example from the web):
http://blog.itechtalk.com/wp-content/2010/10/SMS-Popup-1.png
You are looking for a dialog. See creating dialogs.
Actually smsmpopup uses an activity with theme dialog in it's manifest. Check the src code.
yes.. u want something as a Dialog... but if its an activity.. u can set this paramenter in the androidmanifest file..
android:name=".Pick_Color"
android:label="Pick a Color !"
android:theme="#android:style/Theme.Dialog">
this will make the screen as neat and Dialogish as possible