Skip to content Skip to sidebar Skip to footer

Put Html Link In Edittext Android

I want to put google in edittext and when I click on this text I want to open webview. How can I do that?

Solution 1:

Put your html in a string@

<string url="link">&lt;a href="http://www.google.com">Google&lt;/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());

Solution 2:

Try adding the following code:

yourEditText.setMovementMethod(LinkMovementMethod.getInstance());

Solution 3:

try this

EditText et = (TextView) findViewById(R.id.et);
et.setText(Html.fromHtml("<ahref=\"http://www.google.com/\">Google</a> "));
et.setMovementMethod(LinkMovementMethod.getInstance());

Solution 4:

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

publicvoidopenGoogleWebview()
{
     Intent intent = new Intent(this, GoogleWebviewActivity.class)
}

Post a Comment for "Put Html Link In Edittext Android"