I have a textview with a html string with anchors in it. When I click the textview I want to call eg a method called A, and when I click a link in the textview I want to call a method called B. I got this working but I got a problem: when I click a link, method B is called, but method A is called too. How can I make sure only method B, and not B and A, is called when I click a link?
My code:
for (int i = 0; i < ingevoegd.length(); i++) {
JSONObject soortingevoegd = ingevoegd.getJSONObject(i);
String type = soortingevoegd.getString("type");
if (type.equals("Vis")) {
String link = "<a href = 'com.aquariumzoeken.pro://Soortweergave?selected="
+ naam + "&type=Vis" + "'>" + naam + "</a>";
text = text.replaceAll(naam, link);
}
}
TextView texttv = (TextView) v.findViewById(R.id.textviewer);
texttv.setText(Html.fromHtml(text));
texttv.setMovementMethod(LinkMovementMethod.getInstance());
And the textview onclicklistener:
texttv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
switchToEditMode sw = new switchToEditMode();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Thanks in advance, Simon