Example usage for android.view LayoutInflater cloneInContext

List of usage examples for android.view LayoutInflater cloneInContext

Introduction

In this page you can find the example usage for android.view LayoutInflater cloneInContext.

Prototype

public abstract LayoutInflater cloneInContext(Context newContext);

Source Link

Document

Create a copy of the existing LayoutInflater object, with the copy pointing to a different Context than the original.

Usage

From source file:com.applite.common.PagerSlidingTabStrip.java

public static PagerSlidingTabStrip inflate(Context context, ViewGroup root, boolean attach) {
    LayoutInflater mInflater = LayoutInflater.from(context);
    mInflater = mInflater.cloneInContext(context);
    return (PagerSlidingTabStrip) mInflater.inflate(R.layout.pager_sliding_tab, root, attach);
}

From source file:nz.ac.otago.psyanlab.common.designer.assets.AssetDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    inflater.cloneInContext(new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light));
    return inflater.inflate(R.layout.fragment_designer_asset_detail, container, false);
}

From source file:be.evias.cloudLogin.FragmentProfile.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContext = new ContextThemeWrapper(getActivity(), R.style.AppTheme);
    LayoutInflater localInflater = inflater.cloneInContext(mContext);
    View rootView = localInflater.inflate(R.layout.fragment_profile, container, false);

    TextView email_field = (TextView) rootView.findViewById(R.id.profileEmail);
    TextView name_field = (TextView) rootView.findViewById(R.id.profileName);

    email_field.setText(getCurrentUser().getEmail());
    name_field.setText(getCurrentUser().getName());

    return rootView;
}

From source file:com.mobilesolutionworks.android.managedview.test.DemoInFragment.java

@Override
public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
    LayoutInflater inflater = super.getLayoutInflater(savedInstanceState);
    inflater = inflater.cloneInContext(inflater.getContext());

    inflater.setFactory(this);
    return inflater;
}

From source file:com.ayuget.redface.ui.fragment.BaseFragment.java

/**
 * Inflates fragment root view and deals with view injections through ButterKnife
 *
 * Also applies app custom theme//from   w w w  .  j a  va  2s . c om
 */
protected ViewGroup inflateRootView(@LayoutRes int viewResId, LayoutInflater inflater, ViewGroup container) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(),
            themeManager.getActiveThemeStyle());
    LayoutInflater themedInflater = inflater.cloneInContext(contextThemeWrapper);

    ViewGroup rootView = (ViewGroup) themedInflater.inflate(viewResId, container, false);
    ButterKnife.inject(this, rootView);
    return rootView;
}

From source file:com.example.spellingcoach.tabs.wordlists.WordListsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // create ContextThemeWrapper from the original Activity Context with the custom theme
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.wordlistsListViewTheme);

    // clone the inflater using the ContextThemeWrapper
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);

    // inflate the layout using the cloned inflater, not default inflater
    return localInflater.inflate(R.layout.fragment_tab_wordlists, container, false);
}

From source file:dev.dworks.widgets.adateslider.PickerDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ContextThemeWrapper ctw = new ContextThemeWrapper(getActivity(), mTheme);
    LayoutInflater localInflater = inflater.cloneInContext(ctw);
    View v = localInflater.inflate(R.layout.picker_dialog, container, false);
    FrameLayout frame = (FrameLayout) v.findViewById(R.id.container);
    localInflater.inflate(mLayoutID, frame);

    mDivider = v.findViewById(R.id.divider);
    mDividerOne = v.findViewById(R.id.divider_1);
    mDividerTwo = v.findViewById(R.id.divider_2);
    mDivider.setBackgroundColor(mDividerColor);
    mDividerOne.setBackgroundColor(mDividerColor);
    mDividerTwo.setBackgroundColor(mDividerColor);

    getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);

    mTitleText = (TextView) v.findViewById(R.id.dateSliderTitleText);
    mTitleText.setTextColor(mTextColor);
    mContainer = (SliderContainer) v.findViewById(R.id.dateSliderContainer);
    mContainer.setTheme(mTheme);//from w  w w. ja  va 2s .  co  m

    mContainer.setOnTimeChangeListener(onTimeChangeListener);
    mContainer.setMinuteInterval(minuteInterval);
    mContainer.setTime(mInitialTime);
    if (minTime != null)
        mContainer.setMinTime(minTime);
    if (maxTime != null)
        mContainer.setMaxTime(maxTime);

    mSet = (Button) v.findViewById(R.id.set_button);
    mCancel = (Button) v.findViewById(R.id.cancel_button);
    mSet.setTextColor(mTextColor);
    mSet.setBackgroundResource(mButtonBackgroundResId);
    mSet.setOnClickListener(okButtonClickListener);

    mCancel.setTextColor(mTextColor);
    mCancel.setBackgroundResource(mButtonBackgroundResId);
    mCancel.setOnClickListener(cancelButtonClickListener);

    return v;
}

From source file:com.example.spellingcoach.tabs.students.StudentsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // create ContextThemeWrapper from the original Activity Context with the custom theme
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.studentsListViewTheme);

    // clone the inflater using the ContextThemeWrapper
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);

    return localInflater.inflate(R.layout.fragment_tab_students, container, false);
}

From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java

@SuppressLint("RtlHardcoded")
private void drawOverlay(AccessibilityNodeInfo node, View.OnClickListener onClickListener) {

    mOverlay = new FrameLayout(this);

    // must be encapsulated into FrameLayout for animation
    FrameLayout mAnimatedChild = new FrameLayout(this);
    LayoutInflater systemInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final Context contextThemeWrapper = new ContextThemeWrapper(this, R.style.FixedBottomSheetTheme);
    LayoutInflater inflater = systemInflater.cloneInContext(contextThemeWrapper);

    View child = inflater.inflate(R.layout.fixed_bottom_sheet, null);
    mAnimatedChild.addView(child);/*w  ww . j a v  a 2 s  .c  o m*/

    Button b = (Button) child.findViewById(R.id.fixed_bottom_sheet_button);
    b.setText(R.string.decrypt_with_openkeychain);
    b.setOnClickListener(onClickListener);

    ImageButton close = (ImageButton) child.findViewById(R.id.fixed_bottom_sheet_close);
    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            closeOverlay();
        }
    });

    Rect webviewRect = new Rect();
    node.getBoundsInScreen(webviewRect);

    Display display = mWindowManager.getDefaultDisplay();
    Rect displayRect = new Rect();
    display.getRectSize(displayRect);

    int xpos = webviewRect.left;
    int ypos = webviewRect.top - getStatusBarHeight() < getToolbarHeight() ? getToolbarHeight()
            : webviewRect.top - getStatusBarHeight();

    int width = webviewRect.width();
    int height = webviewRect.bottom < displayRect.height()
            ? webviewRect.bottom - getToolbarHeight() - getStatusBarHeight()
            : displayRect.height() - ypos - getStatusBarHeight();

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(width, height, xpos, ypos,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.windowAnimations = R.style.OverlayAnimation;
    mWindowManager.addView(mOverlay, params);
    mOverlay.addView(mAnimatedChild);
}

From source file:org.dmfs.tasks.InputTextDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final Context contextThemeWrapperLight = new ContextThemeWrapper(getActivity(),
            R.style.ThemeOverlay_AppCompat_Light);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapperLight);

    View view = localInflater.inflate(R.layout.fragment_input_text_dialog, container);

    mEditText = (EditText) view.findViewById(android.R.id.input);
    mErrorText = (TextView) view.findViewById(R.id.error);
    if (savedInstanceState == null && mInitialText != null) {
        mEditText.setText(mInitialText);
    }/*ww  w  . j a  v  a2  s  .  co m*/
    if (savedInstanceState == null && mHint != null) {
        mEditText.setHint(mHint);
    }
    if (mMessage != null) {
        TextView mMessageView = (TextView) view.findViewById(android.R.id.message);
        mMessageView.setText(mMessage);
        mMessageView.setVisibility(View.VISIBLE);
    }
    ((TextView) view.findViewById(android.R.id.title)).setText(mTitle);

    mEditText.requestFocus();
    getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    mEditText.setOnEditorActionListener(this);

    view.findViewById(android.R.id.button1).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handleSave();
        }
    });

    view.findViewById(android.R.id.button2).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handleCancel();
        }
    });

    return view;
}