android - How to maintain instance of fragment -


I have made several pieces in the menu. I called the piece using the switch case. That's why a new example has been made every time. The same example? My code here:

  piece slice = null; Switch (position) {case 0: piece = new piece 1 (); break; Case 1: section = new piece 2 (); break; Case 2: section = new piece 3 (); break; Case 3: Section = New Piece 4 (); break; Case 4: Section = New piece (5); break; } Piece Manager Piece Manager = getFragmentManager (); Fragmentation manager BBT transactions () Replace (R.id.content_frame, fragment) .commit ();  

instead of

  piece slice = null; Fragment = new fragment1 () fragment = new fragment2 ()  

Store pieces in different variables:

  piece slice 1 = faucet; Piece volume 2 = faucet; Fragment1 = new fragment1 () fragment2 = new fragag2 ()  

...

And if only the variable null

< / Div>

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -