I want to put <a href="google.com" target="_blank">google</a>
in edittext and when I click on this text I want to open webview. How can I do that?
Asked
Active
Viewed 1,925 times
0

edi233
- 3,511
- 13
- 56
- 97
-
use this method...setAutoLinkMask() Automatically Finds url and email id and make it clickable... – Aravin Sep 26 '13 at 06:37
4 Answers
1
Try adding the following code:
yourEditText.setMovementMethod(LinkMovementMethod.getInstance());

Szymon
- 42,577
- 16
- 96
- 114
1
Put your html in a string@
<string url="link"><a href="http://www.google.com">Google</a></string>
set String to editText
@
youredittext.setText(Html.fromHtml(getResources().getString(R.string.url)));
For click, set LinkMovementMethod
with necessary action@
youredittext.setMovementMethod(LinkMovementMethod.getInstance());

RobinHood
- 10,897
- 4
- 48
- 97
1
try this
EditText et = (TextView) findViewById(R.id.et);
et.setText(Html.fromHtml("<a href=\"http://www.google.com/\">Google</a> "));
et.setMovementMethod(LinkMovementMethod.getInstance());

swati srivastav
- 635
- 4
- 15
-1
Why do you want that in an EditText??
What if you just use a button with the text "Google", and use it's onclick to call a method in your xml like:
android:onClick="openGoogleWebview"
and then add in your code
public void openGoogleWebview()
{
Intent intent = new Intent(this, GoogleWebviewActivity.class)
}

GeertG
- 158
- 2
- 12