Textview scrollable and clickable - android

I am working on a notepad application for android and it seems I have a litte problem for a textview. Here's the thing: I have a listview of notes, when I click a note, I open another activity which displays the content of my note into a textview. When I click this textview(representing the text from the note), it opens another activity for editing the text (like most of these apps do). The problem is that some of the notes are really long, so I need to make my textview Scrollable. But since I am having a "setOnclickListener" on it, I cannot do that at the same time. I have searched a lot on google and apparently a lot of folks seem to have this problem. Is there a way to achieve my goal?

Ideas:
Use OnGestureListener or OnTouchListener
Use an 'edit' button
Use long press instead of OnClick

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.

xml for dropdown text

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

AOSP: Non-focusable but LongClickable TextView

I just downloaded AOSP and modified TextView for my purpose.
I have added a LongClick Listener to the TextView, which shows a simple Toast.
Since I modified the Android framework, it is reflected into all the apps and entire Android OS.
I have now run into a weird issue where the TextView is getting focus in some places and other underlying widgets are not getting any focus. This is creating lot of issues.
For eg: In Settings app, The 'Wi-Fi' text is receiving focus, but I cannot enter the wi-fi settings unless I click in any empty area in the Wi-Fi list item.
(I hope am clear!)
Another example: I am unable to select the Radio Button just because the text corresponding to Radio Button receives focus.
So my question is:
Is there any way I can make TextView non-focusable but receive Long Click events?
Is there any way I can pass the focus down to the parent layout?
Any other way you can suggest?
(PS: Please do not say what I am doing is right or wrong. It's just a feasibility test for what I am trying to achieve.)
A view does have the attributes "focusable" and "longClickable". Have you tried a combination of these?

Creating a custom action on text link

This is seems like a pretty simple question, but I'm not sure if there's a solution to it. Is it possible to set a custom action for a text link (those blue texts that are underlined) inside a TextView? In other words, is it possible to have a handler do something on an event like onClick on the link?
You need to set the link in the text, and use the autoLink attribute for it. It will use the marked text as link. Otherwise, the only option is to use an OnClickListener as suggested by nicholas.
You can look at the autoLink attribute doc here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink
If your text is: "You will find it at http://www.example.com", and you set android:autoLink="web", then the link will be highlighted and a browser will start after clicking it.
If you are working with an EditText or a TextView, they both have an setOnClickListener() method which you could override.
If you are working with a WebView, and the content created is yours, you can use JavaScript to handle click's of links.
If you are working with a WebView and the content you are viewing is not yours, I am not sure if there is a way to intercept those, but you should still be able to call setOnClickListener() on a WebView, as setOnClickListener() is defined in the View class. I am just not sure how you would tell whether or not a link was clicked in that WebView...
I encountered this situation too, where I have autolink set up in TextViews to automatically handle URLs in TextViews. However, the default behavior is to open the web page in an external browser, so how do we make it open in an in-app browser (for example)?
Underneath the hood, this is handled for TextView by LinkMovementMethod. Hence, the suggestion (by one of the answers) to customize onClickListener() of the TextView is not ideal, as it would involve reimplementing much of what LinkMovementMethod handles, so that it could precisely handle clicks/taps on what are identified as URLs.
More recently (years after this post was made), someone has come up with an enhancement over LinkMovementMethod, known as (what else?) BetterLinkMovementMethod, described in more detail this blog post. I can confirm that it did work for me. With just a few lines of code changes, the TextView autolinks now open in the in-app browser (and clearly, all kinds of other behaviors can be customized as desired). I have no affiliation with BetterLinkMovementMethod or its creators, but am just a grateful user.

highlight the word on longpress android

Hello
In my android application i am using a webview to display apage of contents .
What i require is like if the user longpress on a word then that particular word should be highlighted and should be highlighted even if the user reloads the app again.
Is there any way that i can get this done in android.
Please forward your valuable suggestions.
Thanks in advance:)
Putting it in a WebView is what will make this tricky, if it were just a regular view I would say extend TextView and implement onLongClickListener for it as well. Not sure how to squeeze this into an existing webview though :/

Categories

Resources