List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:Main.java
public static View create(Context context, int layout, ViewGroup parent, boolean attachToRoot) { return LayoutInflater.from(context).inflate(layout, parent, attachToRoot); }
From source file:Main.java
public static View inflate(@NonNull Context context, @NonNull ViewGroup parent, @LayoutRes int layoutRes) { return LayoutInflater.from(context).inflate(layoutRes, parent, false); }
From source file:Main.java
public static final View inflate(final Context pContext, final int pLayoutID, final ViewGroup pViewGroup) { return LayoutInflater.from(pContext).inflate(pLayoutID, pViewGroup, true); }
From source file:Main.java
/** * Creates a custom {@link Toast} with a custom layout View * /*from w ww. java 2s. co m*/ * @param context * the context * @param resId * the custom view * @return the created {@link Toast} */ public static Toast makeCustomToast(Context context, int resId) { View view = LayoutInflater.from(context).inflate(resId, null); Toast t = new Toast(context); t.setDuration(Toast.LENGTH_SHORT); t.setView(view); t.setGravity(Gravity.CENTER, 0, 0); return t; }
From source file:Main.java
public static View inflater(Context context, int layoutId) { return LayoutInflater.from(context).inflate(layoutId, null); }
From source file:Main.java
public static View inflater(Context context, int layoutId, ViewGroup container) { return LayoutInflater.from(context).inflate(layoutId, container); }
From source file:Main.java
public static LayoutInflater getInflater(Context context) { return LayoutInflater.from(context); }
From source file:Main.java
public static View showPopupWindow(Context context, int resId, View root, int paramsType) { View popupView;/* w ww .j a v a 2s. c om*/ popupView = LayoutInflater.from(context).inflate(resId, null); switch (paramsType) { case 1: popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true); break; case 2: popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); break; case 3: popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, true); break; case 4: popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); break; default: popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true); break; } popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.setTouchable(true); popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.showAsDropDown(root); return popupView; }
From source file:com.wellsandwhistles.android.redditsp.common.DialogUtils.java
public static void showSearchDialog(Context context, int titleRes, final OnSearchListener listener) { final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); final EditText editText = (EditText) LayoutInflater.from(context).inflate(R.layout.dialog_editbox, null); alertBuilder.setView(editText);/*w w w . ja v a 2 s . c om*/ alertBuilder.setTitle(titleRes); alertBuilder.setPositiveButton(R.string.action_search, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String query = General.asciiLowercase(editText.getText().toString()).trim(); if (StringUtils.isEmpty(query)) { listener.onSearch(null); } else { listener.onSearch(query); } } }); alertBuilder.setNegativeButton(R.string.dialog_cancel, null); final AlertDialog alertDialog = alertBuilder.create(); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); alertDialog.show(); }
From source file:com.otaupdater.utils.UserUtils.java
public static void showLoginDialog(final Context ctx, String defUsername, final DialogCallback dlgCallback, final LoginCallback loginCallback) { @SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.login_dialog, null); if (view == null) return;/*w w w . j av a2 s . c om*/ final EditText inputUsername = (EditText) view.findViewById(R.id.auth_username); final EditText inputPassword = (EditText) view.findViewById(R.id.auth_password); if (defUsername != null) inputUsername.setText(defUsername); AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.alert_login_title); builder.setView(view); builder.setPositiveButton(R.string.login, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { /* set below */ } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (loginCallback != null) loginCallback.onCancel(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (dlgCallback != null) dlgCallback.onDialogShown(dlg); Button button = dlg.getButton(DialogInterface.BUTTON_POSITIVE); if (button == null) return; button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String username = inputUsername.getText().toString(); final String password = inputPassword.getText().toString(); if (username.length() == 0 || password.length() == 0) { Toast.makeText(ctx, R.string.toast_blank_userpass_error, Toast.LENGTH_LONG).show(); return; } dlg.dismiss(); APIUtils.userLogin(ctx, username, password, new APIUtils.ProgressDialogAPICallback(ctx, ctx.getString(R.string.alert_logging_in), dlgCallback) { @Override public void onSuccess(String message, JSONObject respObj) { try { String realUsername = respObj.getString("username"); String hmacKey = respObj.getString("key"); Config.getInstance(ctx).storeLogin(realUsername, hmacKey); if (loginCallback != null) loginCallback.onLoggedIn(realUsername); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onError(String message, JSONObject respObj) { //TODO show some error } }); } }); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dlgCallback != null) dlgCallback.onDialogClosed(dlg); } }); dlg.show(); }