﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - Crosslight - Change layout programmatically</title><link>http://www.intersoftsolutions.com/Community/Crosslight/Change-layout-programmatically/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Change layout programmatically</title><link>http://www.intersoftsolutions.com/Community/Crosslight/Change-layout-programmatically/</link><pubDate>Tue, 30 Sep 2014 10:15:48 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="color: #1f497d;"&gt;I managed to add TextView into LinearLayout by overriding OnCreate method. The snippet code below shows how.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;public class SimpleActivity : Activity&amp;lt;SimpleViewModel&amp;gt;
{
    #region Constructors

    public SimpleActivity()
        : base(Resource.Layout.MainLayout)
    {
    }

    protected override void OnCreate(global::Android.OS.Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
                                                                   
        LinearLayout mainView = this.FindViewById&amp;lt;LinearLayout&amp;gt;(Resource.Id.Container);

        TextView txtView = new TextView(this);
        txtView.SetTextColor(global::Android.Graphics.Color.ParseColor("#FFFFFF"));
        txtView.SetTextAppearance(this, global::Android.Resource.Style.TextAppearanceMedium);
        txtView.Text = "test";

        mainView.AddView(txtView);
    }

    #endregion
}&lt;/pre&gt;
&lt;p&gt;&lt;span style="color: #1f497d;"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Change layout programmatically</title><link>http://www.intersoftsolutions.com/Community/Crosslight/Change-layout-programmatically/</link><pubDate>Mon, 29 Sep 2014 19:20:25 GMT</pubDate><dc:creator>thomas.albert@tea-net.ch</dc:creator><description>&lt;p&gt;Hello Crosslight Support,&lt;/p&gt;&lt;p&gt;what is the best/recommended way to change layouts programmatically (e.g. adding buttons or textviews)?&lt;/p&gt;&lt;p&gt;I tried this on Android, but I got stuck.&lt;/p&gt;&lt;p&gt;I wasn't able to get the main view of the current activity to add additional "sub"views.&lt;/p&gt;&lt;p&gt;I have the following code as constructor of my activity: &lt;/p&gt;&lt;p&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt; SimpleActivity()&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt;: &lt;/span&gt;&lt;/span&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;Resource&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;Layout&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt;.MainLayout){}&lt;/span&gt;&lt;/span&gt;&lt;br&gt;&lt;/p&gt;&lt;span face="Consolas"&gt;&lt;p&gt;To get a reference to the main view (MainLayout) of the "SimpleActivity" I tried: &lt;/p&gt;&lt;p&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;LinearLayout&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt; mainView = (&lt;/span&gt;&lt;/span&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;&lt;span color="#2b91af" face="Consolas" size="2"&gt;LinearLayout&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt;.FindViewById(&lt;/span&gt;&lt;/span&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;&lt;span color="#0000ff" face="Consolas" size="2"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span face="Consolas" size="2"&gt;&lt;span face="Consolas" size="2"&gt;.ContentLayoutId);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;span face="Consolas"&gt;within OnViewCreated, OnViewInitialized, InitializeView but the mainView variable is always "null".&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span face="Consolas"&gt;Thanks for your support.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span face="Consolas"&gt;Thomas&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>