Fragment setRetainInstance - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Fragment setRetainInstance method.

This code example shows how to use the following methods: setRetainInstance
	 
	public ColorFragment() {  
		this(R.color.white);
	} 
	 
	public ColorFragment(int colorRes) {
		mColorRes = colorRes;
		setRetainInstance(true);
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (savedInstanceState != null)
			mColorRes = savedInstanceState.getInt("mColorRes");
		int color = getResources().getColor(mColorRes);
		// construct the RelativeLayout 
		RelativeLayout v = new RelativeLayout(getActivity());
		v.setBackgroundColor(color);		
		return v;
	} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setRetainInstance
  public ContentFragment() { 
    this(null); 
  } 
   
  public ContentFragment(String url) {
    super(); 
     
    urlToLoad=url;
    setRetainInstance(true);
  } 
   
  @Override 
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                            Bundle savedInstanceState) {
    return(inflater.inflate(R.layout.content_fragment, container, false));
  } 
   
  @Override 
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setRetainInstance, setUserVisibleHint
public class SupportSelectionStateFragment extends Fragment implements SelectionState {
 
  private CommonSelectionStateFragment _common = new CommonSelectionStateFragment();
 
  public SupportSelectionStateFragment() { 
    super(); 
    setRetainInstance(true);
    setUserVisibleHint(false);
  } 
 
  @Override 
  public void onSaveInstanceState(final Bundle state) {
    super.onSaveInstanceState(state);
    _common.onSaveInstanceState(state);
  } 
 
  @Override 
  public void onCreate(final Bundle state) {
    super.onCreate(state);
    _common.onCreate(state);
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setRetainInstance
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) {
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setRetainInstance
	 
	public ColorFragment() {  
		this(R.color.white);
	} 
	 
	public ColorFragment(int colorRes) {
		mColorRes = colorRes;
		setRetainInstance(true);
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (savedInstanceState != null)
			mColorRes = savedInstanceState.getInt("mColorRes");
		int color = getResources().getColor(mColorRes);
		// construct the RelativeLayout 
		RelativeLayout v = new RelativeLayout(getActivity());
		v.setBackgroundColor(color);		
		return v;
	} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Fragment setRetainInstance Questions & Answers:

setRetainInstance Method Overview
Control whether a fragment instance is retained across Activity re-creation (such as from a configuration change).
See Code Examples for other Android Fragment Methods: