0

i use fragment where is list view and on item click i changed this fragment to details. I want to add custom back button inside details view..

I wrote this event

private void _Back_Click(object sender, EventArgs e)
        {
            var fragmentTransaction = this.FragmentManager.BeginTransaction();
            var _fragment = new ForecastRegionListFragment();         
            fragmentTransaction.Attach(_fragment).Commit();
            fragmentTransaction.Show(_fragment);
            fragmentTransaction.Remove(this);

            MyApplication._Back.Click -= _Back_Click;
            MyApplication._Back.Visibility = ViewStates.Invisible;
        } 

but i think that it is not good way to do back. can u advice me better version ?

Nininea
  • 2,671
  • 6
  • 31
  • 57
  • You can just call finish(); in the backbutton code. – Nava2011 Jul 08 '14 at 12:56
  • i don't want to finith application, i want to go back previous fragment – Nininea Jul 08 '14 at 13:04
  • @NinoSvanidze `http://stackoverflow.com/questions/24032956/action-bar-back-button-not-working` check out that answer in that link.In fragment you have to use intent to pass to the activity.And then set the onBackPressed() Code in Activity.Thats it. – Stephen Jul 08 '14 at 14:05

1 Answers1

0

seems like this will help, just programmatically call the back button and attach it to the touch button

Android: Proper Way to use onBackPressed() with Toast

cheers

Community
  • 1
  • 1
CodeBlake
  • 194
  • 3
  • 13
  • I want back from fragment and not from activity. – Nininea Jul 08 '14 at 13:08
  • addToBackStack(null) should be added when you call the new fragments or activity, this adds it to the stack which is navigated when using back button functionality – CodeBlake Jul 08 '14 at 13:19