@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (isOnline()) { super.setContentView(R.layout.fragment_progress); } else { setErrorView(); } }
public void setContentView(int layoutResId) { if (layoutResId == R.layout.error) { super.setContentView(layoutResId); } else { LayoutInflater layoutInflater = LayoutInflater.from(this); View contentView = layoutInflater.inflate(layoutResId, null); setContentView(contentView); } }
@Override protected void onStart() { if (!hasErrorView()) { ensureContent(); if (mContentView == null) { throw new IllegalStateException("Content view must be initialized before"); } } super.onStart(); }