나는 Mono를 처음 사용합니다. Android의 경우 하나의 입력 텍스트 데이터를 activity1.cs의 한 EditText에서 다른 활동의 TextView로 보내려고하지만, 작동하지 않습니다. 하나의 활동에서 다른 활동으로 EditText 데이터 보내기
이
가 Activity1.cs입니다 : 여기 코드입니다public string Item;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button AddButton = FindViewById<Button>(Resource.Id.AddButton);
Button ViewButton = FindViewById<Button>(Resource.Id.ViewButton);
EditText addNewAssignmentField = FindViewById<EditText>(Resource.Id.addNewAssignmentField);
AddButton.Click += delegate
{
if (addNewAssignmentField.Text == "")
{
Toast.MakeText(this, "Please Write Assignment To Add", ToastLength.Short).Show();
}
else
{
Item = addNewAssignmentField.Text;//.ToString();
Toast.MakeText(this, "Assignment Added!", ToastLength.Short).Show();
addNewAssignmentField.Text = "";
ShowMessage(Item); //ignore this
}
};
ViewButton.Click += delegate
{
StartActivity(typeof(ViewListActivity));
};
}
이 다른 활동 :
글고 다른 활동에 글고에서 텍스트를 받고 밤은 Activity1 ac1 = new Activity1();
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "ListLayout" layout resource
SetContentView(Resource.Layout.ListLayout);
Button button1 = FindViewById<Button>(Resource.Id.button1);
var listItemsTxt = new TextView(this);
EditText itemsList = FindViewById<EditText>(Resource.Id.itemsList);
itemsList.Text = ac1.Item;
}
Activity1.cs에
감사합니다!
나는 모노에 대해 모르지만 그 방법은 의도를 통해 이루어 지므로 "Android 용 모노 인 텐트"로 Google에 제안하십시오. – Budius