customizing linkify method in java(Android Studio)
I have in my layout, a TextView
, the id is textView1
. In my java class I have this piece of code:
TextView link1 = (TextView) findViewById(R.id.tJabalEnlace1);
link1.setText("https://stackoverflow.com/");
Linkify.addLinks(link1, Linkify.ALL);
What this does is, initialize the textView
, set the text of it, and linkifies it. It works just fine, but what I would like to do is, make the textView be "Link" and the direction to be the link in the code, but I don't know how.
UPDATE: I wanted to do it with linkify, I found another way of doing it: -Set the text View Clickable in the layout file. -Java:
TextView link1 = (TextView) findViewById(R.id.tJabalEnlace1);
link1.setPaintFlags(Paint.UNDERLINE_TEXT_FLAG);
link1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("https://stackoverflow.com/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);}});
}
链接地址: http://www.djcxy.com/p/74640.html
上一篇: Android链接网址链接非网址