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!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…