【发布时间】:2013-09-26 06:33:34
【问题描述】:
我想把<a href="google.com" target="_blank">google</a> 放在edittext 中,当我点击这个文本时,我想打开webview。我该怎么做?
【问题讨论】:
-
使用这个方法...setAutoLinkMask() 自动查找url和email id并使其可点击...
标签: android
我想把<a href="google.com" target="_blank">google</a> 放在edittext 中,当我点击这个文本时,我想打开webview。我该怎么做?
【问题讨论】:
标签: android
把你的html放在一个字符串中@
<string url="link"><a href="http://www.google.com">Google</a></string>
设置String to editText@
youredittext.setText(Html.fromHtml(getResources().getString(R.string.url)));
对于点击,将LinkMovementMethod 设置为必要的操作@
youredittext.setMovementMethod(LinkMovementMethod.getInstance());
【讨论】:
尝试添加以下代码:
yourEditText.setMovementMethod(LinkMovementMethod.getInstance());
【讨论】:
试试这个
EditText et = (TextView) findViewById(R.id.et);
et.setText(Html.fromHtml("<a href=\"http://www.google.com/\">Google</a> "));
et.setMovementMethod(LinkMovementMethod.getInstance());
【讨论】:
为什么要在 EditText 中使用它??
如果您只使用带有文本“Google”的按钮,并使用它的 onclick 来调用 xml 中的方法,例如:
android:onClick="openGoogleWebview"
然后添加你的代码
public void openGoogleWebview()
{
Intent intent = new Intent(this, GoogleWebviewActivity.class)
}
【讨论】: