Example usage for android.view LayoutInflater inflate

List of usage examples for android.view LayoutInflater inflate

Introduction

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

Prototype

public View inflate(XmlPullParser parser, @Nullable ViewGroup root) 

Source Link

Document

Inflate a new view hierarchy from the specified xml node.

Usage

From source file:Main.java

public static View inflater(LayoutInflater inflater, int layoutId) {
    return inflater.inflate(layoutId, null);
}

From source file:Main.java

public static View inflateLayout(Context context, int id, ViewGroup view) {
    LayoutInflater inflate = LayoutInflater.from(context);
    View result = inflate.inflate(id, view);
    return result;
}

From source file:Main.java

public static View inflater(LayoutInflater inflater, int layoutId, ViewGroup container) {
    return inflater.inflate(layoutId, container);
}

From source file:Main.java

public static View inflate(int layout, ViewGroup root, Context context) {
    LayoutInflater i = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    return i.inflate(layout, root);
}

From source file:Main.java

public static View getView(Context context, int resourceId) {
    LayoutInflater inflater = LayoutInflater.from(context);
    if (resourceId != INVALID) {
        return inflater.inflate(resourceId, null);
    }/*w  w w  .j av a  2  s.c  o  m*/
    return null;
}

From source file:Main.java

public static View addListViewHeaderView(ListView listview, int layoutId, Context context) {
    LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = mInflater.inflate(layoutId, null);
    listview.addHeaderView(view);//from  ww w . jav a  2s.  co m
    return view;
}

From source file:com.grarak.romswitcher.Utils.Utils.java

public static void setupPassword(final Context context) {

    LayoutInflater factory = LayoutInflater.from(context);

    final View btn = factory.inflate(R.layout.password, null);

    mOldPasstext = (TextView) btn.findViewById(R.id.oldpass_text);

    mOldPassword = (EditText) btn.findViewById(R.id.oldpass);
    mNewPassword = (EditText) btn.findViewById(R.id.newpass);
    mConfirmPassword = (EditText) btn.findViewById(R.id.confirmpass);

    if (!mPassfile.exists()) {
        mOldPassword.setVisibility(View.GONE);
        mOldPasstext.setVisibility(View.GONE);
    }//from w  w w .  jav a 2s. co m

    Builder builder = new Builder(context);
    builder.setView(btn).setTitle(context.getString(R.string.setuppass))
            .setNegativeButton(context.getString(R.string.button_cancel),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    })
            .setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    checkOldPass(context);
                }
            }).show();
}

From source file:com.fuzz.android.limelight.model.ChapterTransition.java

public static void getDrawerPosition() {
    LayoutInflater inflater = LimeLight.getActivity().getLayoutInflater();
    View drawerView = inflater.inflate(R.layout.choose_drawer_item, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(LimeLight.getActivity());
    builder.setTitle(R.string.choose_drawer_item);
    builder.setView(drawerView);/*w  w w  .  j av a  2s  . c  o m*/

    final Spinner positionSpinner = (Spinner) drawerView.findViewById(R.id.positionSpinner);

    ArrayList<String> items = new ArrayList<String>();
    for (int i = 0; i < LimeLight.getDrawerList().getAdapter().getCount(); i++) {
        items.add(i + "");
    }

    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(LimeLight.getActivity(),
            android.R.layout.simple_spinner_dropdown_item, items);

    positionSpinner.setAdapter(spinnerArrayAdapter);

    positionSpinner.setSelection(mDrawerItemPosition);

    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mDrawerItemPosition = Integer.valueOf(positionSpinner.getSelectedItem().toString());
        }
    });

    builder.setNegativeButton(R.string.cancel, null);

    builder.create();
    builder.show();
}

From source file:com.adguard.android.commons.BrowserUtils.java

public static void showBrowserInstallDialog(final Context context) {
    // Touch listener for changing colors of CardViews
    View.OnTouchListener touchListener = new View.OnTouchListener() {
        @Override/* w ww  . j av a2s .  com*/
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getActionMasked();
            if (action == MotionEvent.ACTION_DOWN) {
                ((CardView) v).setCardBackgroundColor(R.color.card_view_background_pressed);
            } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL
                    || action == MotionEvent.ACTION_OUTSIDE) {
                ((CardView) v).setCardBackgroundColor(R.color.white);
            }
            return false;
        }
    };

    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View dialogLayout = inflater.inflate(R.layout.select_browser_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialog);
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.setView(dialogLayout);
    final AlertDialog dialog = builder.create();

    View cardView = dialogLayout.findViewById(R.id.browser_yandex);
    cardView.setOnTouchListener(touchListener);
    cardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.startMarket(context, YANDEX_BROWSER_PACKAGE, REFERRER);
            dialog.dismiss();
        }
    });

    cardView = dialogLayout.findViewById(R.id.browser_samsung);
    cardView.setOnTouchListener(touchListener);
    cardView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.startMarket(context, SAMSUNG_BROWSER_PACKAGE, null);
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static RelativeLayout getTextViewForCode(final Context context, final String text) {
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final RelativeLayout codeLayout = (RelativeLayout) inflater.inflate(R.layout.code, null);
    final WebView webView = (WebView) codeLayout.findViewById(R.id.code);
    loadText(webView, text);//w w w .  j a  va  2  s  . c o m

    StackXQuickActionMenu quickActionMenu = new StackXQuickActionMenu(context)
            .addEmailQuickActionItem("Code sample from StackX", text).addCopyToClipboardItem(text);
    final QuickActionMenu actionMenu = quickActionMenu.addItem(R.string.fullscreen, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, FullscreenTextActivity.class);
            intent.putExtra(StringConstants.TEXT, text);
            context.startActivity(intent);
        }
    }).build();

    ImageView imageView = (ImageView) codeLayout.findViewById(R.id.codeQuickActionMenu);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            actionMenu.show(v);
        }
    });

    return codeLayout;
}