I am working on Xamarin Android using C#. I have a XML containing the list of values which I would like to show as radio buttons. These buttons have to be created dynamically. Am unable to do so. Though Xamarin says that they support HTML tags as well but even that is not working.
Asked
Active
Viewed 1,119 times
-1
-
3Please show what you got so far and what you tried. – Cornelius Jul 08 '15 at 10:31
1 Answers
1
Τake a look at this answer by Charlie Collins, on how to create a UI Elements from HTML
I know this example isn't using a Button, but it's the same idea
String needs to be a resource:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="mystring"> You can use regular text, and escaped HTML markup <br /><br /> A simple BOLD example <b>StackOverflow</b>. </string> </resources>
Then get the resource and use
Html.fromHtml()
(if you are using anEditText
, you also need to make sure the buffer is set to SPANNABLE):public class MyActivity extends Activity { TextView myTextView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about); myTextView = (TextView) this.findViewById(R.id.mytextview); myTextView.setText(Html.fromHtml(getResources().getString(R.string.mystring)), TextView.BufferType.SPANNABLE); } ...
Lastly, note that all HTML doesn't work, of course. So depending on your requirements, this might not be entirely useful.
-
@iamlcarus: Please take note of the formatting improvements I've made to your post, and how I've corrected cited your source. Also take note on [this ongoing meta discussion](http://meta.stackoverflow.com/questions/285349/how-to-handle-answers-which-copy-its-whole-content-from-another-answer-with-prop), as to whether answers which are nothing more than copied content are acceptable. – Matt Jul 09 '15 at 17:14