I have a textview with an html string with anchors in it. When I click on the text view that I want to call, for example, method A, and when I click on the link in text form, I want to call method B. I got this, but I have a problem: when I click on the link, method B is called, but method A is also called. How can I make sure that when a link to a link is clicked, only method B is called, not B and A?
My code is:
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 onclicklistener text box:
texttv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { switchToEditMode sw = new switchToEditMode(); } catch (JSONException e) {
Thanks in advance, Simon.
Simon source share