Created
May 8, 2013 03:59
-
-
Save iseebi/5538087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent"> | |
<TextView | |
android:text="Please enter name" | |
android:textAppearance="?android:attr/textAppearanceMedium" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:id="@+id/textView1" /> | |
<EditText | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:id="@+id/nameEditText" /> | |
<Button | |
android:text="Go" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:id="@+id/goButton" /> | |
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Android.App; | |
using Android.Content; | |
using Android.Runtime; | |
using Android.Views; | |
using Android.Widget; | |
using Android.OS; | |
namespace TestApp01 | |
{ | |
[Activity (Label = "TestApp01", MainLauncher = true)] | |
public class Activity1 : Activity | |
{ | |
protected override void OnCreate (Bundle bundle) | |
{ | |
base.OnCreate (bundle); | |
SetContentView (Resource.Layout.MainContainer); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent"> | |
<fragment | |
class="TestApp01.MainFragment" | |
android:id="@+id/fragment1" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> | |
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Android.App; | |
using Android.Views; | |
using Android.Widget; | |
using Android.OS; | |
namespace TestApp01 | |
{ | |
public class MainFragment : Fragment | |
{ | |
private Button GoButton { get; set; } | |
private EditText NameEditText { get; set; } | |
public override Android.Views.View OnCreateView (LayoutInflater inflater, | |
ViewGroup container, | |
Bundle savedInstanceState) | |
{ | |
View mainView = inflater.Inflate(Resource.Layout.Main, container); | |
NameEditText = mainView.FindViewById<EditText> (Resource.Id.nameEditText); | |
GoButton = mainView.FindViewById<Button>(Resource.Id.goButton); | |
GoButton.Click += (sender, e) => { | |
var bundle = new Bundle(); | |
bundle.PutString("name", NameEditText.Text); | |
var transaction = FragmentManager.BeginTransaction(); | |
var fragment = SubFragment.Instantiate(Activity, "SubFragment", bundle); | |
transaction.Replace(Resource.Id.fragment1, fragment); | |
transaction.Commit(); | |
Activity.FragmentManager.ExecutePendingTransactions(); | |
}; | |
return mainView; | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:minWidth="25px" | |
android:minHeight="25px"> | |
<TextView | |
android:text="Medium Text" | |
android:textAppearance="?android:attr/textAppearanceMedium" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:id="@+id/messageText" /> | |
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Android.App; | |
using Android.Content; | |
using Android.OS; | |
using Android.Runtime; | |
using Android.Util; | |
using Android.Views; | |
using Android.Widget; | |
namespace TestApp01 | |
{ | |
public class SubFragment : Fragment | |
{ | |
private TextView MessageText { get; set; } | |
public override void OnCreate (Bundle savedInstanceState) | |
{ | |
base.OnCreate (savedInstanceState); | |
} | |
public override Android.Views.View OnCreateView (LayoutInflater inflater, | |
ViewGroup container, | |
Bundle savedInstanceState) | |
{ | |
View mainView = inflater.Inflate(Resource.Layout.Sub, container); | |
MessageText = mainView.FindViewById<TextView> (Resource.Id.messageText); | |
var name = Arguments.GetString("Name"); | |
MessageText.Text = string.Format("Hello! {0}!", name); | |
return mainView; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment