Example usage for android.view LayoutInflater from

List of usage examples for android.view LayoutInflater from

Introduction

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

Prototype

public static LayoutInflater from(Context context) 

Source Link

Document

Obtains the LayoutInflater from the given context.

Usage

From source file:eu.e43.impeller.uikit.ActivityAdapter.java

@Override
public Holder onCreateViewHolder(ViewGroup viewGroup, int type) {
    LayoutInflater inf = LayoutInflater.from(m_ctx);
    return new Holder(inf);
}

From source file:android.support.design.widget.BaseTransientBottomBar.java

/**
 * Constructor for the transient bottom bar.
 *
 * @param parent The parent for this transient bottom bar.
 * @param content The content view for this transient bottom bar.
 * @param contentViewCallback The content view callback for this transient bottom bar.
 *//*from ww  w  .  ja va  2s .co m*/
protected BaseTransientBottomBar(@NonNull ViewGroup parent, @NonNull View content,
        @NonNull ContentViewCallback contentViewCallback) {
    if (parent == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null parent");
    }
    if (content == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null content");
    }
    if (contentViewCallback == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null callback");
    }

    mTargetParent = parent;
    mContentViewCallback = contentViewCallback;
    mContext = parent.getContext();

    ThemeUtils.checkAppCompatTheme(mContext);

    LayoutInflater inflater = LayoutInflater.from(mContext);
    // Note that for backwards compatibility reasons we inflate a layout that is defined
    // in the extending Snackbar class. This is to prevent breakage of apps that have custom
    // coordinator layout behaviors that depend on that layout.
    mView = (SnackbarBaseLayout) inflater.inflate(R.layout.design_layout_snackbar, mTargetParent, false);
    mView.addView(content);

    ViewCompat.setAccessibilityLiveRegion(mView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(mView, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    ViewCompat.setFitsSystemWindows(mView, true);
    ViewCompat.setOnApplyWindowInsetsListener(mView, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            // Copy over the bottom inset as padding so that we're displayed
            // above the navigation bar
            v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
                    insets.getSystemWindowInsetBottom());
            return insets;
        }
    });

    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}

From source file:com.code.android.vibevault.ShowDetailsScreen.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.nowPlaying: //Open playlist activity
        Intent i = new Intent(ShowDetailsScreen.this, NowPlayingScreen.class);

        startActivity(i);//from  w w w.j av  a2s .c o  m
        break;
    case R.id.recentShows:
        Intent rs = new Intent(ShowDetailsScreen.this, RecentShowsScreen.class);

        startActivity(rs);
        break;
    case R.id.scrollableDialog:
        AlertDialog.Builder ad = new AlertDialog.Builder(this);
        ad.setTitle("Help!");
        View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null);
        ((TextView) v.findViewById(R.id.DialogText)).setText(R.string.show_details_screen_help);
        ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int arg1) {
            }
        });
        ad.setView(v);
        ad.show();
        break;
    case R.id.emailLink:
        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("plain/text");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                "Great show on archive.org: " + show.getArtistAndTitle());
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                "Hey,\n\nYou should listen to " + show.getArtistAndTitle() + ".  You can find it here: "
                        + show.getShowURL() + "\n\nSent using VibeVault for Android.");
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
        break;
    case R.id.downloadShow:
        for (int j = 0; j < downloadLinks.size(); j++) {
            downloadLinks.get(j).setDownloadShow(show);
            dService.addSong(downloadLinks.get(j));
        }
        break;
    default:
        break;
    }
    return true;
}

From source file:com.blueverdi.rosietheriveter.PhotoViewActivity.java

private void hintScreen() {
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    showHint = mPrefs.getBoolean(GalleryFragment.showHintPref, true);
    if (showHint) {
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.photo_hint_screen, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        CheckBox cb = (CheckBox) view.findViewById(R.id.chkWelcome);
        cb.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (((CheckBox) buttonView).isChecked()) {
                    showHint = false;/*from w ww .j ava 2 s.  co  m*/
                } else {
                    showHint = true;
                }

            }

        });
        Button b = (Button) view.findViewById(R.id.exitPhotoHintButton);
        b.setOnClickListener(this);
        builder.setTitle(null);
        builder.setView(view);
        hintDialog = builder.show();
    }

}

From source file:com.smartx.bill.mepad.mestore.uimgloader.AbsListViewBaseActivity.java

protected void setDialog() {
    dialog = new ProgressDialog(this, R.style.welcome_dialog);
    dialog.setCancelable(false);//from www. ja  v  a  2s. co m
    dialog.show();
    LayoutInflater inflater = LayoutInflater.from(this);
    View v = inflater.inflate(R.layout.wlecome_dialog, null);// view
    LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view);// 
    // main.xmlImageView
    ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
    TextView tipTextView = (TextView) v.findViewById(R.id.tipTextView);// ??
    // 
    Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.loading_animation);
    // ImageView
    spaceshipImage.startAnimation(hyperspaceJumpAnimation);
    // tipTextView.setText(msg);// ?
    dialog.setContentView(layout);
}

From source file:com.actionbarsherlock.internal.widget.ActionBarContextView.java

public void initForMode(final ActionMode mode) {
    if (mClose == null) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        mClose = (NineLinearLayout) inflater.inflate(R.layout.abs__action_mode_close_item, this, false);
        addView(mClose);//from w  ww .  j av a2s  .c o  m
    } else if (mClose.getParent() == null) {
        addView(mClose);
    }

    View closeButton = mClose.findViewById(R.id.abs__action_mode_close_button);
    closeButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mode.finish();
        }
    });

    final MenuBuilder menu = (MenuBuilder) mode.getMenu();
    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.dismissPopupMenus();
    }
    mActionMenuPresenter = new ActionMenuPresenter(mContext);
    mActionMenuPresenter.setReserveOverflow(true);

    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    if (!mSplitActionBar) {
        menu.addMenuPresenter(mActionMenuPresenter);
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(null);
        addView(mMenuView, layoutParams);
    } else {
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.MATCH_PARENT;
        layoutParams.height = mContentHeight;
        menu.addMenuPresenter(mActionMenuPresenter);
        mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        mMenuView.setBackgroundDrawable(mSplitBackground);
        mSplitView.addView(mMenuView, layoutParams);
    }

    mAnimateInOnLayout = true;
}

From source file:br.edu.ifpb.breath.slidingtabs.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from w ww .  jav  a 2 s. c o  m
        TextView tabTitleView = null;
        ImageView tabIconView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            tabIconView = (ImageView) tabView.findViewById(mTabViewImageViewId);
        }

        if (tabView == null && !mUseIcons) {
            tabView = createDefaultTabView(getContext(), 0);
            tabView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (tabView == null && mUseIcons) {
            tabView = createDefaultTabView(getContext(), 1);
            tabView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
            tabTitleView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (tabIconView == null && ImageView.class.isInstance(tabView)) {
            tabIconView = (ImageView) tabView;
            tabIconView.setAlpha(i == 0 ? 1.0f : 0.25f);
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        if (mUseIcons) {
            tabIconView.setVisibility(View.VISIBLE);
            if (tabTitleView != null)
                tabTitleView.setVisibility(View.GONE);

            if (mIcons.containsKey(i))
                tabIconView.setImageDrawable(mIcons.get(i));
        } else {
            tabTitleView.setVisibility(View.VISIBLE);
            if (tabIconView != null)
                tabIconView.setVisibility(View.GONE);

            tabTitleView.setText(adapter.getPageTitle(i));
            tabTitleView.setTextColor(mTextColor);
        }

        tabView.setOnClickListener(tabClickListener);
        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }
    }
}

From source file:android_network.hetnet.vpn_service.AdapterRule.java

public AdapterRule(Activity context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    this.context = context;
    this.inflater = LayoutInflater.from(context);

    if (prefs.getBoolean("dark_theme", false))
        colorChanged = Color.argb(128, Color.red(Color.DKGRAY), Color.green(Color.DKGRAY),
                Color.blue(Color.DKGRAY));
    else/* w w w  . j a  v a  2 s .  co  m*/
        colorChanged = Color.argb(128, Color.red(Color.LTGRAY), Color.green(Color.LTGRAY),
                Color.blue(Color.LTGRAY));

    TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary });
    try {
        colorText = ta.getColor(0, 0);
    } finally {
        ta.recycle();
    }

    TypedValue tv = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorOn, tv, true);
    colorOn = tv.data;
    context.getTheme().resolveAttribute(R.attr.colorOff, tv, true);
    colorOff = tv.data;

    colorGrayed = ContextCompat.getColor(context, R.color.colorGrayed);

    iconSize = Util.dips2pixels(48, context);
}

From source file:android.support.v7.view.menu.ListMenuItemView.java

private LayoutInflater getInflater() {
    if (mInflater == null) {
        mInflater = LayoutInflater.from(getContext());
    }
    return mInflater;
}

From source file:com.bonsai.wallet32.SweepKeyActivity.java

private void addAccountHeader(TableLayout table) {
    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.receive_to_header, table, false);

    TextView tv = (TextView) row.findViewById(R.id.header_btc);
    tv.setText(mBTCFmt.unitStr());//from w  w w  . java  2  s  . c  om

    table.addView(row);
}