String randomString = XXXX.getString();
if(randomString .contains("XXXX"))
{
TextView tv = new TextView(this);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setText(randomString +"/n"+Html.fromHtml("<a href=https://play.google.com/store/apps/details?id=com.xxxxxxxxx>Click Here</a>"));
AlertDialog dialog = new AlertDialog.Builder(activity.this)
.setView(tv)
.setPositiveButton("OK!", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
}
})
.show();
}
这项工作:
tv.setText(Html.fromHtml("<br><a href=https://play.google.com/store/apps/details?id=com.xxxxxxxxx>Click Here</a>"));
没有randomString+
我一经放入randomString + Html.fromHtml....单击此处"将成为常规文本
As soon as I put the randomString+Html.fromHtml.... The "Click Here" become a regular text
但是我也想将randomString放在textview内.
But I would like to put the randomString inside the textview as well.
您在URL周围缺少引号.试试:
You're missing quotes around your URL. Try:
Html.fromHtml("<a href='https://play.google.com/store/apps/details?id=com.xxxxxxxxx'>Click Here</a>")
请注意URL周围的单引号.
Note the single quotes around the URL.