List of usage examples for android.view LayoutInflater cloneInContext
public abstract LayoutInflater cloneInContext(Context newContext);
From source file:com.nextgis.libngui.dialog.StyledDialogFragment.java
@Nullable @Override//from ww w . j a v a2 s . c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // http://stackoverflow.com/a/15496425 LayoutInflater localInflater = inflater.cloneInContext(mContext); View view = localInflater.inflate(R.layout.sdf_layout, container, false); mBaseView = (RelativeLayout) view.findViewById(R.id.base); mTitleView = (LinearLayout) view.findViewById(R.id.title); mTitleIconView = (ImageView) view.findViewById(R.id.title_icon); mTitleTextView = (TextView) view.findViewById(R.id.title_text); mTitleDivider = view.findViewById(R.id.title_divider); mDialogBodyScroll = (ScrollView) view.findViewById(R.id.dialog_body_scroll); mDialogBodyLayoutScrolled = (LinearLayout) view.findViewById(R.id.dialog_body_scrolled); mDialogBodyLayout = (LinearLayout) view.findViewById(R.id.dialog_body); mButtons = (LinearLayout) view.findViewById(R.id.buttons); mButtonPositive = (Button) view.findViewById(R.id.button_positive); mButtonNegative = (Button) view.findViewById(R.id.button_negative); if (null != mMessageId) { setMessageView(); mMessage.setText(mMessageId); } if (null != mMessageText) { setMessageView(); mMessage.setText(mMessageText); } if (null != mView) { if (mAddScrollForView) { mDialogBodyScroll.setVisibility(View.VISIBLE); mDialogBodyLayoutScrolled.addView(mView); } else { mDialogBodyLayout.setVisibility(View.VISIBLE); mDialogBodyLayout.addView(mView); } } if (getShowsDialog()) { // http://stackoverflow.com/a/9409391 int[] attrs = new int[] { R.attr.sdf_background }; TypedArray ta = mContext.obtainStyledAttributes(attrs); Drawable background = ta.getDrawable(0); ta.recycle(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mBaseView.setBackground(background); } else { mBaseView.setBackgroundDrawable(background); } mTitleView.setVisibility(View.VISIBLE); if (null != mIconId) { mTitleIconView.setVisibility(View.VISIBLE); mTitleIconView.setImageResource(mIconId); } if (null != mTitleId) { mTitleTextView.setText(mTitleId); } if (null != mTitleText) { mTitleTextView.setText(mTitleText); } if (null != mTitleDividerVisibility) { mTitleDivider.setVisibility(mTitleDividerVisibility); } if (null != mPositiveTextId) { mButtons.setVisibility(View.VISIBLE); mButtonPositive.setVisibility(View.VISIBLE); mButtonPositive.setText(mPositiveTextId); } if (null != mPositiveText) { mButtons.setVisibility(View.VISIBLE); mButtonPositive.setVisibility(View.VISIBLE); mButtonPositive.setText(mPositiveText); } if (null != mNegativeTextId) { mButtons.setVisibility(View.VISIBLE); mButtonNegative.setVisibility(View.VISIBLE); mButtonNegative.setText(mNegativeTextId); } if (null != mNegativeText) { mButtons.setVisibility(View.VISIBLE); mButtonNegative.setVisibility(View.VISIBLE); mButtonNegative.setText(mNegativeText); } if (null != mOnPositiveClickedListener) { mButtons.setVisibility(View.VISIBLE); mButtonPositive.setVisibility(View.VISIBLE); mButtonPositive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mOnPositiveClickedListener) { mOnPositiveClickedListener.onPositiveClicked(); } dismiss(); } }); } if (null != mOnNegativeClickedListener) { mButtons.setVisibility(View.VISIBLE); mButtonNegative.setVisibility(View.VISIBLE); mButtonNegative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mOnNegativeClickedListener) { mOnNegativeClickedListener.onNegativeClicked(); } dismiss(); } }); } } return view; }
From source file:net.goldenspiral.fetlifeoss.ui.fragments.FetLifeFragment.java
/** * * @param inflater The LayoutInflater object that can be used to inflate any views in the fragment, * @param container If non-null, this is the parent view that the fragment's * UI should be attached to. The fragment should not add the view itself, * but this can be used to generate the LayoutParams of the view. * @param theme to use for the new UI/*from w ww . j a v a 2 s .c om*/ * @param layout to inflate * * @return Return the View for the fragment's UI, or null. */ protected View inflate(final LayoutInflater inflater, final ViewGroup container, int theme, int layout) { // create ContextThemeWrapper from the original Activity Context with the custom theme final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme); // clone the inflater using the ContextThemeWrapper LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper); // inflate the layout using the cloned inflater, not default inflater return localInflater.inflate(layout, container, false); }
From source file:net.goldenspiral.fetlifeoss.ui.fragments.FetLifeFragment.java
protected BINDING bind(final LayoutInflater inflater, final ViewGroup container, int theme, int layout) { // create ContextThemeWrapper from the original Activity Context with the custom theme final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme); // clone the inflater using the ContextThemeWrapper LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper); // inflate the layout using the cloned inflater, not default inflater // @TODO AndroidStudio shows an error for FetLifeDatabinder - see it for details return DataBindingUtil.inflate(localInflater, layout, container, false, FetLifeDatabinder.INSTANCE); }
From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java
private LayoutInflater getThemeInflater(LayoutInflater inflater) { return mThemeWrapper == null ? inflater : inflater.cloneInContext(mThemeWrapper); }
From source file:com.rastating.droidbeard.fragments.ShowFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.SickBeardTheme_LightActionBar); LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper); View root = localInflater.inflate(R.layout.fragment_show, container, false); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe_refresh_layout); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override//from w w w .j ava 2s .c om public void onRefresh() { onRefreshButtonPressed(); swipeRefreshLayout.setRefreshing(true); } }); swipeRefreshLayout.setColorSchemeResources(R.color.materialPrimaryDark, R.color.materialPrimary, R.color.navigation_list_item_selected, R.color.unaired_episode_background); if (savedInstanceState != null) { mShowSummary = (TVShowSummary) savedInstanceState.getParcelable("summary"); } // Get references to all required views. mBanner = (ImageView) root.findViewById(R.id.banner); mLoadingImage = (ImageView) root.findViewById(R.id.loading); mDataContainer = root.findViewById(R.id.data); mAirs = (TextView) root.findViewById(R.id.airs); mStatus = (TextView) root.findViewById(R.id.status); mLocation = (TextView) root.findViewById(R.id.location); mQuality = (TextView) root.findViewById(R.id.quality); mLanguage = (TextView) root.findViewById(R.id.language); mLanguageIcon = (ImageView) root.findViewById(R.id.language_icon); mFlattenFolders = (ImageView) root.findViewById(R.id.flatten_folders); mPaused = (ImageView) root.findViewById(R.id.paused); mAirByDate = (ImageView) root.findViewById(R.id.air_by_date); mSeasonContainer = (LinearLayout) root.findViewById(R.id.season_container); mPauseButton = (Button) root.findViewById(R.id.toggle_pause); mDeleteButton = (Button) root.findViewById(R.id.delete); mPauseButton.setOnClickListener(this); mDeleteButton.setOnClickListener(this); mDataContainer.setAlpha(0.0f); mLoadingImage.setAlpha(1.0f); mLoadingImage.startAnimation(new LoadingAnimation()); onRefreshButtonPressed(); return root; }
From source file:com.granita.tasks.QuickAddDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // create ContextThemeWrapper from the original Activity Context with the custom theme final Context contextThemeWrapperLight = new ContextThemeWrapper(getActivity(), R.style.ThemeOverlay_AppCompat_Light); final Context contextThemeWrapperDark = new ContextThemeWrapper(getActivity(), R.style.Base_Theme_AppCompat); LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapperLight); View view = localInflater.inflate(R.layout.fragment_quick_add_dialog, container); ViewGroup headerContainer = (ViewGroup) view.findViewById(R.id.header_container); localInflater = inflater.cloneInContext(contextThemeWrapperDark); localInflater.inflate(R.layout.fragment_quick_add_dialog_header, headerContainer); if (savedInstanceState == null) { if (mListId >= 0) { mSelectedListId = mListId;//from ww w .j av a 2 s. co m } } mColorBackground = view.findViewById(R.id.color_background); mColorBackground.setBackgroundColor(mLastColor); mListSpinner = (Spinner) view.findViewById(R.id.task_list_spinner); mTaskListAdapter = new TasksListCursorSpinnerAdapter(getActivity(), R.layout.list_spinner_item_selected_quick_add, R.layout.list_spinner_item_dropdown); mListSpinner.setAdapter(mTaskListAdapter); mListSpinner.setOnItemSelectedListener(this); mEditText = (EditText) view.findViewById(android.R.id.input); mEditText.requestFocus(); getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); mEditText.setOnEditorActionListener(this); mEditText.addTextChangedListener(this); mConfirmation = view.findViewById(R.id.created_confirmation); mContent = view.findViewById(R.id.content); mSaveButton = view.findViewById(android.R.id.button1); mSaveButton.setOnClickListener(this); mSaveAndNextButton = view.findViewById(android.R.id.button2); mSaveAndNextButton.setOnClickListener(this); view.findViewById(android.R.id.edit).setOnClickListener(this); mAuthority = getString(R.string.org_dmfs_tasks_authority); afterTextChanged(mEditText.getEditableText()); setListUri(TaskLists.getContentUri(mAuthority), LIST_LOADER_VISIBLE_LISTS_FILTER); return view; }
From source file:com.ycdyng.onemulti.MultiFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); if (DEBUG)/*from ww w . j a v a 2 s.c om*/ Log.d(TAG, getClass().getSimpleName() + ": onCreateView"); int layoutResId = getLayoutResourceId(); if (layoutResId <= 0) { throw new IllegalStateException("Layout resource id can't be zero"); } int themeResId = getThemeResId(); if (themeResId != R.style.AppTheme) { ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getActivity(), themeResId); inflater = inflater.cloneInContext(contextThemeWrapper); } mColorPrimaryDark = getColorPrimaryDark(inflater.getContext().getTheme()); setStatusBarColor(); mRootView = inflater.inflate(layoutResId, container, false); onCreateView(mRootView, container, savedInstanceState); return mRootView; }
From source file:com.afwsamples.testdpc.SetupManagementFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { mLogoUri = (Uri) savedInstanceState.getParcelable(EXTRA_PROVISIONING_LOGO_URI); mCurrentColor = savedInstanceState.getInt(EXTRA_PROVISIONING_MAIN_COLOR); } else {/*w ww. j a v a 2s . c o m*/ mLogoUri = resourceToUri(getActivity(), R.drawable.ic_launcher); mCurrentColor = getResources().getColor(R.color.teal); } // Use setupwizard theme final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.SetupTheme); LayoutInflater themeInflater = inflater.cloneInContext(contextThemeWrapper); View view = themeInflater.inflate(R.layout.setup_management_fragment, container, false); SetupWizardLayout layout = (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout); NavigationBar navigationBar = layout.getNavigationBar(); navigationBar.setNavigationBarListener(this); navigationBar.getBackButton().setText(R.string.exit); mNavigationNextButton = navigationBar.getNextButton(); mNavigationNextButton.setText(R.string.setup_label); mSetupManagementMessage = (TextView) view.findViewById(R.id.setup_management_message_id); mSetupOptions = (RadioGroup) view.findViewById(R.id.setup_options); mSetupOptions.setOnCheckedChangeListener(this); mSkipUserConsent = (CheckBox) view.findViewById(R.id.skip_user_consent); mKeepAccountMigrated = (CheckBox) view.findViewById(R.id.keep_account_migrated); mSkipEncryption = (CheckBox) view.findViewById(R.id.skip_encryption); mParamsView = view.findViewById(R.id.params); mParamsIndicator = (ImageButton) view.findViewById(R.id.params_indicator); mParamsIndicator.setOnClickListener(this); view.findViewById(R.id.color_select_button).setOnClickListener(this); mColorValue = (TextView) view.findViewById(R.id.selected_color_value); mColorValue.setText(String.format(ColorPicker.COLOR_STRING_FORMATTER, mCurrentColor)); mColorPreviewView = (ImageView) view.findViewById(R.id.preview_color); mColorPreviewView.setImageTintList(ColorStateList.valueOf(mCurrentColor)); Intent launchIntent = getActivity().getIntent(); if (LaunchIntentUtil.isSynchronousAuthLaunch(launchIntent)) { Account addedAccount = LaunchIntentUtil.getAddedAccount(launchIntent); if (addedAccount != null) { view.findViewById(R.id.managed_account_desc).setVisibility(View.VISIBLE); // Show the user which account needs management. TextView managedAccountName = (TextView) view.findViewById(R.id.managed_account_name); managedAccountName.setVisibility(View.VISIBLE); managedAccountName.setText(addedAccount.name); } else { // This is not an expected case, sync-auth is triggered by an account being added so // we expect to be told which account to migrate in the launch intent. We don't // finish() here as it's still technically feasible to continue. Toast.makeText(getActivity(), R.string.invalid_launch_intent_no_account, Toast.LENGTH_LONG).show(); } } return view; }
From source file:com.binomed.showtime.android.screen.fav.CineShowTimeFavFragment.java
/** Called when the activity is first created. */ @Override/*from w ww. j a v a 2 s .co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Bug fix do to pb of theme. Was forced to set manually the theme. SharedPreferences pref = PreferenceManager .getDefaultSharedPreferences(fragmentInteraction.getMainContext()); String defaultTheme = fragmentInteraction.getMainContext().getResources() .getString(R.string.preference_gen_default_theme); String theme = pref.getString( fragmentInteraction.getMainContext().getResources().getString(R.string.preference_gen_key_theme), defaultTheme); int themeRessource = R.style.Theme_Dark_Night; if (!theme.equals(defaultTheme)) { themeRessource = R.style.Theme_Shine_the_lite; } LayoutInflater newInflater = inflater .cloneInContext(new ContextThemeWrapper(fragmentInteraction.getMainContext(), themeRessource)); View mainView = newInflater.inflate(R.layout.fragment_fav, container, false); tracker = fragmentInteraction.getTracker(); mainContext = fragmentInteraction.getMainContext(); initViews(mainView); initListeners(); this.model = new ModelFavFragment(); return mainView; }
From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java
private LayoutInflater getThemeInflater(LayoutInflater inflater) { if (mThemeWrapper == null) { return inflater; } else {/*from www . jav a2 s. c om*/ return inflater.cloneInContext(mThemeWrapper); } }