Refine search
Activity activity = ...; AlertDialog dialog = ...; // retrieve display dimensions Rect displayRectangle = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); // inflate and adjust layout LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.your_dialog_layout, null); layout.setMinimumWidth((int)(displayRectangle.width() * 0.9f)); layout.setMinimumHeight((int)(displayRectangle.height() * 0.9f)); dialog.setView(layout);
data = d; inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader = new ImageLoader(activity.getApplicationContext()); View vi = convertView; if (convertView == null) { vi = inflater.inflate(R.layout.item_composer, null); TextView title = (TextView) vi.findViewById(R.id.item_title); // title TextView price = (TextView) vi.findViewById(R.id.price);
/** * Initialized at any moment of app life cycle to determine screen shape and size * @param activity */ public static void initShapeWear(Activity activity){ WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); getScreenSize(wm); initShapeDetection(activity.getWindow().getDecorView().findViewById(android.R.id.content)); }
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader = new ImageLoader(activity.getApplicationContext()); vi = inflater.inflate(R.layout.photos_item, null); holder.imgPhoto = (ImageView)vi.findViewById(R.id.grid_item_image);
// The method that displays the popup. private void showStatusPopup(final Activity context, Point p) { // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.llStatusChangePopup); LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.status_popup_layout, null); // Creating the PopupWindow changeStatusPopUp = new PopupWindow(context); changeStatusPopUp.setContentView(layout); changeStatusPopUp.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT); changeStatusPopUp.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); changeStatusPopUp.setFocusable(true); // Some offset to align the popup a bit to the left, and a bit down, relative to button's position. int OFFSET_X = -20; int OFFSET_Y = 50; //Clear the default translucent background changeStatusPopUp.setBackgroundDrawable(new BitmapDrawable()); // Displaying the popup at the specified location, + offsets. changeStatusPopUp.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y + OFFSET_Y); }
this.layoutInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.applyList = applyList; viewerino = this.layoutInflater.inflate(R.layout.spinner_apply_item, null); TextView id = (TextView)viewerino.findViewById(R.id.txtApplyID); TextView name = (TextView)viewerino.findViewById(R.id.txtApplyName); Apply apply = this.applyList.get(position); id.setText(apply.GetID());
if (view == null) { LayoutInflater inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(row, null); holder.tvTitle = (TextView) view.findViewById(R.id.menu_title); holder.imgView = (ImageView) view.findViewById(R.id.menu_icon); holder.tvUnread = (TextView) view.findViewById(R.id.unread_count); view.setTag(holder); } else {
@Override protected void onPreExecute() { super.onPreExecute(); View view; if (popupWindow == null) { LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.loading_circle, null); popupWindow = new PopupWindow(view, 200, 220); } popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景 popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.showAtLocation(mContext.getWindow().getDecorView(), Gravity.CENTER, 0, 0); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { RequestThreadPool.finish(); cancel(true); } }); }
activity = a; data=d; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader=new ImageLoader(activity.getApplicationContext()); R.layout.horrizontallistitem, null); imgitem = (ImageView) retval .findViewById(R.id.hlvItem);
if (view == null) { LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.listitem, null); if (listElement != null) { view.setOnClickListener(listElement.getOnClickListener()); ImageView icon = (ImageView) view.findViewById(R.id.icon); TextView text1 = (TextView) view.findViewById(R.id.text1); TextView text2 = (TextView) view.findViewById(R.id.text2); if (icon != null) { icon.setImageDrawable(listElement.getIcon());
public static void displayLevelUp(int level, Activity activity) { LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toastText, (ViewGroup) activity.findViewById(R.id.abs__action_bar_container)); // this row
private void setPin() { final Dialog d = new Dialog(getActivity(), R.style.Theme_Document_DailogPIN); d.getWindow().setWindowAnimations(R.style.DialogExitNoAnimation); View view = new PinViewHelper((LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE), null, null) { public void onEnter(String password) { super.onEnter(password); confirmPin(password); d.dismiss(); } public void onCancel() { super.onCancel(); d.dismiss(); } }.getView(); view.findViewById(R.id.logo).setVisibility(View.GONE); d.setContentView(view); d.show(); }
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader = new ImageLoader(activity.getApplicationContext()); if (convertView == null)vi = inflater.inflate(R.layout.item_list_promotion, null); TextView PromoID = (TextView) vi.findViewById(R.id.PromoID); TextView PromoName = (TextView) vi.findViewById(R.id.PromoName); TextView PromoImage = (TextView) vi.findViewById(R.id.PromoImage); TextView PromoDesc = (TextView) vi.findViewById(R.id.PromoDesc); TextView PromoCate = (TextView) vi.findViewById(R.id.PromoCate);
private void showPopup(final Activity context) { LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.popup_layout); LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layoutPopup = layoutInflater.inflate(R.layout.layout_popup, viewGroup); popup = new PopupWindow(context); popup.setContentView(layoutPopup); popup.setWidth(LayoutParams.WRAP_CONTENT); popup.setHeight(LayoutParams.WRAP_CONTENT); popup.setFocusable(true); popup.showAtLocation(layoutPopup, Gravity.CENTER, 0, 0); }
CommentViewHolder(View itemView) { super(itemView); avatar = itemView.findViewById(R.id.article_user_image); btnReplyCz = itemView.findViewById(R.id.btn_reply_cz); btnMore = itemView.findViewById(R.id.btn_more); username = itemView.findViewById(R.id.replay_author); index = itemView.findViewById(R.id.replay_index); replyTime = itemView.findViewById(R.id.replay_time); comment = itemView.findViewById(R.id.html_text); labelLz = itemView.findViewById(R.id.bt_lable_lz); comment.setOnLongClickListener(view -> { String user = datalist.get(getAdapterPosition()).username; String content = comment.getText().toString().trim(); ClipboardManager cm = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); if (cm != null) { cm.setPrimaryClip(ClipData.newPlainText(null, content)); Toast.makeText(activity, "已复制" + user + "的评论", Toast.LENGTH_SHORT).show(); } return true; }); avatar.setOnClickListener(v -> { if (datalist.get(getAdapterPosition()).uid > 0) { UserDetailActivity.openWithAnimation( activity, datalist.get(getAdapterPosition()).username, avatar, datalist.get(getAdapterPosition()).uid); } }); btnReplyCz.setOnClickListener(this); btnMore.setOnClickListener(this); }
inflater = (LayoutInflater)_activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewHolder holder; if (convertView == null) { vi = inflater.inflate(resource, null); holder=new ViewHolder(); holder.carYear = (TextView)vi.findViewById(R.id.carYear); holder.carMake = (TextView)vi.findViewById(R.id.carMake); holder.carModel = (TextView)vi.findViewById(R.id.carModel); holder.carColor = (TextView)vi.findViewById(R.id.carColor); holder.assetTag = (TextView)vi.findViewById(R.id.assetTag);
public class RAdapter extends ArrayAdapter<Consumption> { private Activity activity; private ArrayList<Consumption> meals; private LayoutInflater inflater = null; public RAdapter (Activity act, int resource, ArrayList<Consumption> arrayList) { super(act, resource, arrayList); this.activity = act; this.meals= arrayList; inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public View getView(final int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { view = inflater.inflate(R.layout.result_row, parent, false); } //remaining code return view; } }
private void confirmPin(final String pin) { final Dialog d = new Dialog(getActivity(), R.style.Theme_Document_DailogPIN); d.getWindow().setWindowAnimations(R.style.DialogEnterNoAnimation); PinViewHelper pinViewHelper = new PinViewHelper((LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE), null, null) { public void onEnter(String password) { super.onEnter(password); view.findViewById(R.id.logo).setVisibility(View.GONE); pinViewHelper.setInstruction(R.string.confirm_pin); d.setContentView(view);
activity = a; data=d; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); File cacheDir = StorageUtils.getOwnCacheDirectory(a, "MyFolderCache"); vi = inflater.inflate(R.layout.row, null); vh.iv=(ImageView)vi.findViewById(R.id.ivv); vh.pb= (ProgressBar)vi.findViewById(R.id.pb); vh.tv = (TextView) vi.findViewById(R.id.textView1); vh.tv1= (TextView) vi.findViewById(R.id.textView2);
/** * Inflate view from exit xml layout * * @return the root view of {@link VideoControllerView} */ private View makeControllerView() { LayoutInflater inflate = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mRootView = inflate.inflate(R.layout.media_controller, null); initControllerView(); return mRootView; }