android.app.Activity.getSystemService()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中android.app.Activity.getSystemService()方法的一些代码示例,展示了Activity.getSystemService()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getSystemService()方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:getSystemService

Activity.getSystemService介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: eliotstocker/Light-Controller

/**
 * 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));
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

// 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);
}

代码示例来源:origin: stackoverflow.com

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());

代码示例来源:origin: stackoverflow.com

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 {

代码示例来源:origin: aa112901/remusic

@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);
    }
  });
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: facebook/facebook-android-sdk

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());

代码示例来源:origin: stackoverflow.com

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

代码示例来源:origin: gigabytedevelopers/FireFiles

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();
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

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);
}

代码示例来源:origin: freedom10086/Ruisi

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);
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

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;
   }
 }

代码示例来源:origin: gigabytedevelopers/FireFiles

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);

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: brucetoo/VideoControllerView

/**
 * 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;
}

相关文章

微信公众号

最新文章

更多

Activity类方法