How to get selection event from all EditText areas - android

I'm trying provide a Android Service that makes possible to do some actions when user make selection on any TextView (messages,books etc). But I don't know how to get this events outside my Activity.
I can add listener for specific TextView
mTextView.setCustomSelectionActionModeCallback
But I want get event (like setCustomSelectionActionModeCallback) from all TextViews.
I hope for your help!

I'm trying provide a Android Service that makes possible to do some actions when user make selection on any TextView (messages,books etc).
This is not possible. Each application handles its own action modes, context menus, etc. when text is selected.

Related

Android: Can I put text data in a 'textView' of another app

I have a service that shows an always-on-top clickable floating button on screen irrespective of the context. (User can switch apps and the floating button will always show)(already implemented)
I want to implement such that, whenever user clicks on an EditText, in ANY app, and click the floating button, it should put some text in that EditText.
First I want to know if this is possible atleast? If yes, How!
Let me know if the above para is not enough to make sense what I meant.
Any help will be appreciated.
The only way to do this is create a service that works as an input service, say a custom keyboard.
You need to take permission android.permission.BIND_INPUT_METHOD to do so.
Actually, you do not have rights to do so. But there is a way of doing which is by creating an input service. InputMethodService | Android Developers

Is there Text Selection Listener in WebView

Does Android provides text selection listener in WebView? For example, user select text in web view. Selected text will be shown in toast.
If there is no such listener, how to implement this idea in other ways?
PS. Please note that I do not mean copying or some action modes.
As far as I know, WebView handles text selection internally and does not provide any listeners regarding this.
The selection is updated when user moves the cursor on the web page. One possible way to achieve your goal, is to call WebViewClassic.getSelection() whenever user moves the cursor during text selection. Since this is not a public API, you may need to utilize Java Reflection.
So you may also need to override onTouchEvent(), in your App to decide whether user has entered selection mode and especially when s/he moves the cursor. If yes, calling WebViewClassic.getSelection() will result in a string of what has been selected.

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?

Navigation to other activities by clicking on certain words in text

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

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