Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7937295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:29:32+00:00 2026-06-03T22:29:32+00:00

I have an EditText view in my Android app. I need inner links in

  • 0

I have an EditText view in my Android app. I need “inner links” in it, this means that I need some buttons or span inside EditText and with onClick to this button I can do some actions (not redirect to web page).
I realized this buttons with ClickableSpan() like this

linkWord = "my link";
link = new SpannableString(linkWord);
cs = new ClickableSpan(){
private String w = linkWord;
    @Override
    public void onClick(View widget) {
    wrd.setText(w);
    }
};
link.setSpan(cs, 0, linkWord.length(), 0);
et.append(link);

For make this span clickable I used

et.setMovementMethod(LinkMovementMethod.getInstance());

“Inner links” works fine, but after using et.setMovementMethod() copy and paste items are disable on OnLongClick menu. And this is a problem, because I need “links” in EditText and copy text from this view in the same time.

I have idea to set in listener OnLongClickListener something like removeMovementMethod() for temporary disable “links” function and use menu with copy/paste and after coping text switch on setMovementMethod() method again. But I don’t know how to realize this.

Can you help me? You may be there are some another ways…

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:29:33+00:00Added an answer on June 3, 2026 at 10:29 pm

    I solved this problem and may be this will be interesting for someone…

    For clickable links inside EditText I used

    et.setMovementMethod(LinkMovementMethod.getInstance());
    

    in this case in longClick menu there are not copy/paste items.
    For activate them I need back to normal EditText state, I can do it with:

    et.setMovementMethod(ArrowKeyMovementMethod.getInstance());
    

    After this method links will not work but appear normal longClick menu.

    Therefore I added new item to the context menu and switched between this two options:

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
        if(et.getSelectionStart() == -1){ // in case of setMovementMethod(LinkMovementMethod.getInstance())
            menu.add(0, 1, 0, "Enable copy");
        }
        else{
            menu.add(0, 2, 0, "Enable links");
        }
    }
    @Override
    public boolean onContextItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case 1:
              et.setMovementMethod(ArrowKeyMovementMethod.getInstance());
              et.setSelection(0, 0);
                  //re-register EditText for context menu:
              unregisterForContextMenu(et);
              registerForContextMenu(et);
              break;
          case 2:
              et.setMovementMethod(LinkMovementMethod.getInstance());
              break;
          }
          return true;
      }
    

    Also I registered EditText for context menu:

    registerForContextMenu(et);
    

    Have a hope that this will help someone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is what I have: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import
I have a EditText view, <EditText android:layout_weight=1 android:id=@+id/etMiktar android:layout_width=0dp android:layout_height=wrap_content android:hint=@string/miktarHint android:focusable=false> </EditText> And
I have a custom dialog with one editText view and two buttons ok and
I have EditText in my XML as <!-- Inside RelativeLayout --> <EditText android:id=@+id/edtEmail android:layout_width=match_parent
package walmart.namespace; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView;
I am writing a simple android app which have a edittext and a button.
package com.parseador.prueba; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class main extends
I have a logic error in a simple android app; I have 3 Buttons
I have a list view, editText and button. editText and button are my footer
I have an activity with a custom view which extends EditText in it. Usually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.