Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Open alertdialog from part of string?
    primarykey
    data
    text
    <p>I have a CheckBox with a string that says "I have read and understood the terms and conditions". Now I want to make the words "terms and conditions" to a link which opens a alertdialog where the terms and conditions can be read. Nothing special.</p> <p>I'm thinking something in the line of:</p> <pre><code>&lt;string name="cont_agree"&gt;I have read and understood the &lt;a ref="open alertdialog"&gt;terms and conditions.&lt;/a&gt;&lt;/string&gt; </code></pre> <p>Is it possible, and what should I use where it now says "open alertdialog"? If it can't be done this way, how should I do?</p> <p><strong>Addition:</strong> To open a url you would use this code:</p> <pre><code>&lt;string name="cont_agree"&gt;&lt;a ref="http://www.stackoverflow.com"&gt;Stackoverflow&lt;/a&gt;&lt;/string&gt; </code></pre> <p>But how do you open a alertdialog, or say another screen, from a string? I have seen apps who does this so it is possible, of course, but how?</p> <p>EDIT: This is the code I use for the SpannableStringBuilder:</p> <pre><code>SpannableStringBuilder text = new SpannableStringBuilder(); text.append(getString(R.string.before)); //Now create a ClickableSpan ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View view) { d.show(); //Here dialog will be displayed } }; //Now append the TOS string text.append(getString(R.string.popup)); //Declare that the "TOS" string is a clickableSpan text.setSpan(clickableSpan, getString(R.string.before).length(),getString(R.string.before).length()+getString(R.string.popup).length(), 0); //Check on API setSpan method ((CheckBox)findViewById(yourview)).setMovementMethod(LinkMovementMethod.getInstance()); ((CheckBox)findViewById(yourview)).setText(text, BufferType.SPANNABLE); </code></pre> <p>I still get some markers at the first "text.append" line. Multiple markers at this line:</p> <ul> <li>Return type for the method is missing </li> <li>Syntax error on token ")", { expected after this token </li> <li>R.string.before cannot be resolved to a type </li> <li>Syntax error on token ")", invalid VariableDeclaratorId </li> <li>Syntax error on token "append", Identifier expected after this token</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload