Can I hook when user copy or paste on TextView?

When user copy or paste on TextView, Is there anyone explains me what happen on TextView. If some methods called while user click 'Copy' or 'Paste' in menus, I'd like to hook them and replace them with my own one.

Here is what I want to do. 1. user copy or paste some string to my TextView. 2. some string copied and paste on my Textview. 3. Before some string is added on Textview, I want to check or change string.


Asked by: Robert952 | Posted: 24-01-2022






Answer 1

You should be able to do this with the onTextContextMenuItem() method checking for copy or paste.

Alternatively you can use a TextWatcher to monitor changes in a TextView but this doesn't differentiate between typing and cutting and pasting. Add a TextWatcher with the addTextChangedListener() method.

Answered by: Adrian995 | Posted: 25-02-2022



Similar questions

android - How to bind more then one column to a textview

I am curious if there is a way to bind more then one db column to a resource. I need to bind more information to R.id.secondLine then just the difficulty column. But I'm unsure how to go about this? I'm currently subclassing SimpleCursorAdapter. Should I subclass another adapter? If so How to do I go about it? Cursor activityHikes = mDbAdapter.fetchAllHikes(false); startManagingCursor(activityHikes)...


Android TextView Text not getting wrapped

Can anyone tell me what's going wrong with the text? Text longer than one line doesn't wrap to the next line but goes beyond the screen. Following is the code: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="4dip"> <LinearL...


android - How to display HTML in TextView?

I have simple HTML: <h2>Title</h2><br> <p>description here</p> I want to display HTML styled text it in TextView. How to do this?


how to change text in Android TextView

I tried to do this @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); t=new TextView(this); t=(TextView)findViewById(R.id.TextView01); t.setText("Step One: blast egg"); try { Thread.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printSta...


android - Color of the text in TextView changes color

In android, when I press on a TextView, the text changes color (from white to grey). Can you please tell me how can I disable that functionality? Thank you.


Maximum line length on Android TextView

I'm putting a formatted single line text (no \n's) to a noneditable TextView. In the navigation of the program, the text can be changed. On some text, the TextView shrinks to 0x0 pixel and I can see nothing! I added some menus to truncate the text 10 characters each time and I found that if the number of characters are larger than 4470, the TextView shrinks. Splitting the text into several lines by putting \n in be...


android - How to bind more then one column to a textview

I am curious if there is a way to bind more then one db column to a resource. I need to bind more information to R.id.secondLine then just the difficulty column. But I'm unsure how to go about this? I'm currently subclassing SimpleCursorAdapter. Should I subclass another adapter? If so How to do I go about it? Cursor activityHikes = mDbAdapter.fetchAllHikes(false); startManagingCursor(activityHikes)...


Android TextView Text not getting wrapped

Can anyone tell me what's going wrong with the text? Text longer than one line doesn't wrap to the next line but goes beyond the screen. Following is the code: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="4dip"> <LinearL...


Ordered lists inside an Android TextView

I want to display an ordered list inside a TextView, for example: 1) item 1 2) item 2 Using the following layout: <TextView android:text="<ol><li>item 1\n</li><li>item 2\n</li></ol> /> I get: item 1 item 2 How can I change the bullets to numbers? Thanks.


android - How to display HTML in TextView?

I have simple HTML: <h2>Title</h2><br> <p>description here</p> I want to display HTML styled text it in TextView. How to do this?


how to change text in Android TextView

I tried to do this @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); t=new TextView(this); t=(TextView)findViewById(R.id.TextView01); t.setText("Step One: blast egg"); try { Thread.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printSta...


android - Color of the text in TextView changes color

In android, when I press on a TextView, the text changes color (from white to grey). Can you please tell me how can I disable that functionality? Thank you.


How can you display upside down text with a textview in Android?

How can you display upside down text with a textview in Android? In my case I have a 2 player game, where they play across from each other. I want to display test to the second player oriented to them. This was the solution I implemented after AaronMs advice The class that does the overriding, bab.foo.UpsideDownText package bab.foo; import android.content.Context; import andr...


textview - How to know all id's that i have in the file main.xml in android?

i'm new at Android world, and i have a doubt, is there any method that give me the name of the id's i create in main.xml? For example i have this: main.xml <TextView android:id="@+id/text1" android:layout_width="70px" android:layout_height="70px" android:text="Google" /> <TextView android:id="@+id/text2" android:layout_width="70px" android:layout_h...


How do I add a newline to a TextView in Android?

When I define a TextView in xml, how do I add a new line to it? \n seems not to work. <TextView android:id="@+id/txtTitlevalue" android:text="Line1 -\nLine2" android:layout_width="54dip" android:layout_height="fill_parent" android:textSize="11px" />






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top