Main_Activity
[Activity(Label = "Project", MainLauncher = true)]
public class Main_Activity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
RequestWindowFeature(WindowFeatures.NoTitle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main_Layout);
ImageButton _Back_Button = (ImageButton)FindViewById(Resource.Id._Back_Button);
TextView _Title_Text = (TextView)FindViewById(Resource.Id._Title_Text);
ImageButton _Exit_Button = (ImageButton)FindViewById(Resource.Id._Exit_Button);
_Title_Text.Text = "Setting";
FragmentTransaction _Setting_Content_Adatper = this.FragmentManager.BeginTransaction();
Project.Fragments.Setting_Content_Fragment _Setting_Content = new Project.Fragments.Setting_Content_Fragment();
_Setting_Content_Adatper.Replace(Resource.Id._Adapter_Content, _Setting_Content);
_Setting_Content_Adatper.Commit();
_Back_Button.Click += (s, e) =>
{
_Title_Text.Text = "Setting";
FragmentTransaction _Main_Fragment = this.FragmentManager.BeginTransaction();
Project.Fragments.Setting_Content_Fragment Setting_Main_Fragment = new Project.Fragments.Setting_Content_Fragment();
_Main_Fragment.Replace(Resource.Id._Adapter_Content, Setting_Main_Fragment);
_Main_Fragment.AddToBackStack(null);
_Main_Fragment.Commit();
};
_Exit_Button.Click += (s, e) =>
{
Finish();
};
}
}
}
Setting_Fragment:
public class Setting_Content_Fragment : Fragment
{
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your fragment here
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View _Setting_Content = inflater.Inflate(Resource.Layout.Setting_Content_Layout, container, false);
Button _General_Button = (Button)_Setting_Content.FindViewById(Resource.Id._btnGeneral);
LayoutInflater _Change = (LayoutInflater)Activity.GetSystemService(Context.LayoutInflaterService);
View _Change_Text = _Change.Inflate(Resource.Layout.Main_Layout, null);
TextView _Title_Text = (TextView)_Change_Text.FindViewById(Resource.Id._Title_Text);
_General_Button.Click += (s, e) =>
{
_Title_Text.Text = "General";
FragmentTransaction _Main_Fragment = this.FragmentManager.BeginTransaction();
Project.Fragments.General_Content.General_Main_Fragment General_Main_Fragment = new Project.Fragments.General_Content.General_Main_Fragment();
_Main_Fragment.Replace(Resource.Id._Adapter_Content, General_Main_Fragment);
_Main_Fragment.Commit();
};
return _Setting_Content;
}
}
}
现在从Setting_Fragment中调用Main_Active中的TextView。
当我按下Setting_Fragment上的按钮时,我想更改TextView中的文本。
我无法做到。
这应该是什么解决办法?