I want to display a text where certain words lead to other activities within the application.
Is there a more convenient way to achieve it other than having a bunch of TextViews along with buttons (with the clickable words and a transparent background) side by side?
Just the bunch of TextViews and their onClick(s) should do, you wouldn't need the Buttons..
You can take a look at the Linkify class, that searches for some predefined links in the text such as phone numbers, e-mail addresses and web links and automatically makes them clickable and leading to the corresponding activities when clicked. I think there is a possibility of adding your own pattern to recognize words in the text and bind them to activities you want to be used for those words. Hope this helps.
Please check both of the links
http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/
handle textview link click in my android app
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 looking to achieve the functionality of an AutocompleteTextView but slightly different. Instead of getting a drop-down list with suggestions i want it to complete the sentence for me.
For example: i type abc and i get completed, with the rest of the text in grey: abc1#etc.etc and then click a button to keep this text or keep writing to filter this even further.
Do you think is is achievable somehow?
I have looked my problem up so far but all the answers i found involved a drop-down list, perhaps i haven't looked deep enough.
Why don't you try to implement a custom view?
Basically, you need to the same things that the AutoCompleteTextView does but instead of displaying N elements into the drop down list you have to add the first option to your EditText.
Have a look at:
TextWatcher in order to see how detect the user input and progress
You can then play with indexes and spannables in order to keep track of the data input by the user and the data that you are suggesting.
One thing that I don't like about this idea is the fact that if you have got:
Germans
Germany
...
You need to type a lot of letters without the possibility to choose something different from the solution that you are providing.
use below example ... i think help you...
http://teamandroid4u.blogspot.in/2012/06/autocompletetextview-example.html
I have used this forum when I didn't know how to do something, but now I have decided to begin participating in it.
I would like to know how could I do a dropdown text (maybe it has a specific name and that's why I don't find any results on the internet). I mean, I have some tags in the screen (About, Company, Contact, ...). Each of these tags has a down arrow on the right side, and when I click it, it has to display (and hide if it's clicked again).
Here are the links with the images of what I want to do.
http://i45.tinypic.com/4fzoso.png
http://i47.tinypic.com/2u5886q.png
Thank you in advance!
You should use an ExpandableListView component.
There is a tutorial for it here.
Finally I did it with ImageViews and TextViews using the property android:visibility. Now that it's a static version is working properly. I hope that it continues working well when taking the information from the DB
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.
I have a large text view that I am styling with a SpannableStringBuilder. I want to be able to assign custom click event handlers to certain spans of text. For example, if I click a superscript character I want it to pop up a toast with some information about what the superscript references. So far I have found linkify which helps to make regular expression type of things like emails and phone numbers launch appropriate activities. What I want to be able to do is define a span and its styling and assign a click handler to it. I haven't found anything built in that supports this kind of functionality and so I'm asking for anyone with a fresh idea of how to do this. Thanks.
The only thing I can think of is for you to take a look at the Android source code for the Linkify class and see how that does it.
Take a look at extending ClickableSpan.
http://developer.android.com/reference/android/text/style/ClickableSpan.html
URLSpan which is the span used to Linkify, is an example implementation of ClickableSpan.
http://developer.android.com/reference/android/text/style/URLSpan.html