I am currently working on an interactive book for Android in C# (right now I am doing a test version of it).
I store strings in the file Strings.xml (default file for strings).
In the Main.axml file I created a TextView:
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txttest1" />
This is just basic stuff to contain my strings where the story would be stored.
In the Strings.xml file is a test string:
<string name="storytest1">This is where a piece of the story will go, bla bla, once
upon a time there was our Hero who did this and that...
</string>
So in this TextView txttest1 I want to load this string. In my MainActivity.cs file I did this:
namespace InteractiveBookTest
{
[Activity (Label = "InteractiveBookTest", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
private TextView mTextView;
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
string customstring = "Here I should retrieve storytest1";
mTextView = FindViewById<TextView> (Resource.Id.txttest1);
mTextView.Text = customstring;
}
}
}
How can I do this?