I am trying to get the URL text from a link when it is pressed/clicked on and store it into a string. The reason is there are different types of URL's that I am working with that is in the text. The text comes from a JSON into a database stored into the system. When I click a link, it just opens a browser so I need to have it do something else depending on the URL. I assume I do something in the onClick method. Right now I have this in my class:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRoot = inflater.inflate(R.layout.frag_video, container, false);
tvBody = (TextView) mRoot.findViewById(R.id.body);
tvBody.setClickable(true);
tvBody.setMovementMethod(LinkMovementMethod.getInstance());
Linkify.addLinks(tvBody, Linkify.WEB_URLS);
tvBody.setOnClickListener(onClickListener);
return mRoot;
}
OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (v == mRoot.findViewById(R.id.body)) {
}
}
};