This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAdapter(value = {"bind:textContentClickable", "bind:textContentClick"}, requireAll = true) | |
public static void onContentClick(TextView textView, String[] content, final View.OnClickListener clickListener) { | |
String originalText = textView.getText().toString(); | |
SpannableString ss = new SpannableString(originalText); | |
for (int index = 0; index < content.length; index++) { | |
int indexStarting = originalText.indexOf(content[index]); | |
int lastIndex = indexStarting + content[index].length(); | |
ss = applyClickToTextContent(ss, content[index], indexStarting, lastIndex, clickListener); | |
} | |
textView.setText(ss); |