Code example for Fragment

Methods: setRetainInstance

0
import android.view.ViewGroup; 
import android.widget.TextView; 
 
public class NewFragment extends Fragment {
 
	public NewFragment(){ 
		setRetainInstance(true);
	} 
	 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.main_page_layout, null);
		TextView textView = (TextView)view.findViewById(R.id.tv_text);
		textView.setText("This is a new fragment");
		return view;
	} 
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
Contextual code suggestions in your IDE  Get Codota for Java