Code example for Fragment

Methods: setRetainInstance

import android.view.ViewGroup; 
import android.widget.TextView; 
public class NewFragment extends Fragment {
	public NewFragment(){ 
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.main_page_layout, null);
		TextView textView = (TextView)view.findViewById(;
		textView.setText("This is a new fragment");
		return view;
	public void onCreate(Bundle savedInstanceState) {
Connect your IDE to all the code out there  Get Codota for Java