コード例 #1
0
 public void setIndeterminate(boolean z) {
   if (this.mProgressBar.isIndeterminate() != z) {
     LayoutParams layoutParams = (LayoutParams) this.mProgressBar.getLayoutParams();
     if (z) {
       layoutParams.width = -2;
       layoutParams.height = -2;
       layoutParams.gravity = 17;
     } else {
       layoutParams.width = -1;
       layoutParams.height =
           (int) TypedValue.applyDimension(1, 1.0f, getResources().getDisplayMetrics());
       layoutParams.gravity = 48;
     }
     this.mProgressBar.setLayoutParams(layoutParams);
     this.mProgressBar.setIndeterminate(z);
   }
 }
コード例 #2
0
  public void setSize() {

    int valPxList = densityToPixel(getDeviceDensity());
    mListView = (ListView) v.findViewById(android.R.id.list);
    LayoutParams lpArticle = (LayoutParams) mListView.getLayoutParams();
    lpArticle.height = noOfItem * valPxList;
    mListView.setLayoutParams(lpArticle);
  }
コード例 #3
0
ファイル: NewGameFragment.java プロジェクト: Qw4z1/greed
 private EditText addPlayerEdittext(int playerNumber, LayoutInflater inflater) {
   EditText playerText = (EditText) new EditText(getActivity());
   LayoutParams params = (LayoutParams) mPlayerNameContainer.getLayoutParams();
   params.height = LayoutParams.WRAP_CONTENT;
   params.width = LayoutParams.MATCH_PARENT;
   playerText.setLayoutParams(params);
   playerText.setHint(getResources().getString(R.string.player) + " " + playerNumber);
   mPlayerNameContainer.addView(playerText);
   return playerText;
 }
コード例 #4
0
  private void updateUI() {

    setContentView(R.layout.quick_contact);
    ImageView ivAvatar = (ImageView) this.findViewById(R.id.iv_avatar);

    if (contact != null) {
      Bitmap bitmap =
          NmsContactApi.getInstance(mContext).getAvatarViaEngineContactId(contact.getId());
      if (bitmap != null) {
        ivAvatar.setImageBitmap(bitmap);
      }
    }

    TextView tvName = (TextView) this.findViewById(R.id.tv_name);
    tvName.setText(nativeContact.name);

    ListView lvPhone = (ListView) this.findViewById(R.id.lv_phonelist);

    LayoutParams lp = (LayoutParams) lvPhone.getLayoutParams();
    if (nativeContact.numbers.size() > 2) {
      lp.height = this.getResources().getDimensionPixelOffset(R.dimen.phone_list_quick);
    }

    lvPhone.setLayoutParams(lp);

    PhoneListAdapter adapter = new PhoneListAdapter(this);
    lvPhone.setAdapter(adapter);

    lvPhone.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            call(nativeContact.numbers.get(arg2).number);
          }
        });
  }
コード例 #5
0
  /** 界面预设 */
  private void prepare() {
    if (listNews.getHeaderViewsCount() > 0) {
      return;
    }
    animRight =
        new RotateAnimation(
            -30, 30f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animRight.setDuration(1000);
    animRight.setAnimationListener(listener);
    animLeft =
        new RotateAnimation(
            30f, -30f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animLeft.setDuration(1000);
    animLeft.setAnimationListener(listener);
    View viewHead = LayoutInflater.from(this.getActivity()).inflate(R.layout.div_home_head, null);
    listNews.addHeaderView(viewHead);
    scrollEntry = (HorizontalScrollViewEx) viewHead.findViewById(R.id.home_scroll_entry);
    scrollEntry.setHorizontalScrollViewListenner(
        new HorizontalScrollViewEx.HorizontalScrollViewListenner() {
          @Override
          public void onScrollChanged(int x, int y, int oldx, int oldy) {
            if (x > oldx && x > 50) {
              imgDot1.setImageResource(R.drawable.icon_dot_unselected);
              imgDot2.setImageResource(R.drawable.icon_dot_selected);
            } else if (x < oldx && x < 50) {
              imgDot1.setImageResource(R.drawable.icon_dot_selected);
              imgDot2.setImageResource(R.drawable.icon_dot_unselected);
            }
          }
        });
    viewEntry1 = (View) viewHead.findViewById(R.id.home_layout_entry1);
    viewEntry2 = (View) viewHead.findViewById(R.id.home_layout_entry2);
    viewEntry3 = (View) viewHead.findViewById(R.id.home_layout_entry3);
    viewEntry4 = (View) viewHead.findViewById(R.id.home_layout_entry4);
    viewEntry5 = (View) viewHead.findViewById(R.id.home_layout_entry5);
    viewEntry6 = (View) viewHead.findViewById(R.id.home_layout_entry6);
    btnRegion.getBackground().setAlpha(200);
    btnSearch.getBackground().setAlpha(200);
    btnBell.setImageAlpha(200);
    imgDot1 = (ImageView) viewHead.findViewById(R.id.home_image_dot1);
    imgDot2 = (ImageView) viewHead.findViewById(R.id.home_image_dot2);
    browser = (ScrollWebView) viewHead.findViewById(R.id.home_browser);

    DisplayMetrics metrics = new DisplayMetrics();
    this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    LayoutParams lp = (LayoutParams) browser.getLayoutParams();
    lp.height = metrics.widthPixels * 7 / 10;
    browser.setLayoutParams(lp);

    browser.getSettings().setJavaScriptEnabled(true);
    browser.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    browser.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Intent intent = new Intent(HomeActivity.this.getActivity(), BrowserActivity.class);
            intent.putExtra("url", url);
            startActivity(intent);
            browser.pauseTimers();
            browser.resumeTimers();
            return true;
          }

          @Override
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            browser.loadUrl("about:blank");
          }
        });

    View viewActivity1 = (View) viewHead.findViewById(R.id.home_layout_left);
    viewActivity1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String token = "";
            if (null != Me.instance) {
              token = Me.instance.token;
            }
            String regionId = "";
            if (null != Profile.instance().region) {
              regionId = String.valueOf(Profile.instance().region.id);
            }
            Helper.openBrowser(
                HomeActivity.this.getActivity(), Networking.fetchURL("activity1", token, regionId));
          }
        });
    View viewActivity2 = (View) viewHead.findViewById(R.id.home_layout_right);
    viewActivity2.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String token = "";
            if (null != Me.instance) {
              token = Me.instance.token;
            }
            String regionId = "";
            if (null != Profile.instance().region) {
              regionId = String.valueOf(Profile.instance().region.id);
            }
            Helper.openBrowser(
                HomeActivity.this.getActivity(), Networking.fetchURL("activity2", token, regionId));
          }
        });
    this.getActivity().findViewById(R.id.home_layout_header).bringToFront();
  }
コード例 #6
0
ファイル: BuAlertDailog.java プロジェクト: treejames/bu
  /**
   * 通过 LayoutInflater 扩展UI
   *
   * @param context
   * @param title
   * @param layoutId
   * @param listener
   * @return
   */
  public static Dialog builder(
      final Context context,
      String title,
      String message,
      int layoutId,
      final AlertLayoutInflaterListener listener) {
    final Dialog dialog = new Dialog(context, R.style.IPone_Dialog_Bg);
    dialog.setContentView(R.layout.bu_alert_dailog);
    DisplayMetrics _dm = BuScreenHolder.matchParent(context, dialog.getWindow());

    TextView titleTv = ((TextView) dialog.findViewById(R.id.dialog_title));
    titleTv.setText(title);

    TextView tv = ((TextView) dialog.findViewById(R.id.dialog_message));
    tv.setGravity(listener.getGravity());
    tv.setText(message);
    LinearLayout dialog_extends = (LinearLayout) dialog.findViewById(R.id.dialog_extends);

    // dialog_extends.removeAllViews();
    final View child = LayoutInflater.from(context).inflate(layoutId, null);
    LayoutParams layoutParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    layoutParams.height = _dm.heightPixels / 4;
    dialog_extends.addView(child, layoutParams);

    if (BuStringUtils.isEmpety(title)) {
      titleTv.setVisibility(View.GONE);
    }

    if (listener.hindBtn() == HIND_BTN_TYPE.COMFIRM) {
      dialog.findViewById(R.id.ok_rl).setVisibility(View.GONE);
    } else if (listener.hindBtn() == HIND_BTN_TYPE.CACEL) {
      dialog.findViewById(R.id.cancel_rl).setVisibility(View.GONE);
    }

    String confirmText = context.getString(R.string.prompt_confirm);
    String cancelText = context.getString(R.string.prompt_cancel);

    if (!BuStringUtils.isEmpety(listener.getConfirmTxt())) {
      confirmText = listener.getConfirmTxt();
    }
    if (!BuStringUtils.isEmpety(listener.getCancleTxt())) {
      cancelText = listener.getCancleTxt();
    }
    listener.onInflater(dialog, child);

    final Button confirm = ((Button) dialog.findViewById(R.id.confirm));
    final Button cancel = ((Button) dialog.findViewById(R.id.cancel));
    OnClickListener clickListener =
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (null != listener) {
              if (v.getId() == confirm.getId()) {
                listener.onConfirm(context, dialog);
              } else if (v.getId() == cancel.getId()) {
                listener.onCancel(dialog);
              }
            }
          }
        };

    confirm.setText(confirmText);
    cancel.setText(cancelText);

    confirm.setOnClickListener(clickListener);
    cancel.setOnClickListener(clickListener);
    return dialog;
  }
コード例 #7
0
ファイル: WeatherView.java プロジェクト: heibai01/bts_work
        @Override
        public void handleMessage(Message msg) {
          if (msg.what == WEATHER_IS_READY) { // 利用handler发送延时消息,根据用户指定更新时间,更新天气
            if (mWeatherContainer.getChildCount() != 0) {
              mWeatherContainer.removeAllViews();
            }
            // String cityCode = config.getCityCode();
            String temperature = config.getShowType() > 0 ? "f" : "c";
            // showWeatherInfos("2161853", temperature);
            showWeatherInfos(temperature);
            handler.sendEmptyMessageDelayed(
                WEATHER_IS_READY, config.getUpdateFrequency() * 60 * 60);
          } else if (msg.what == GET_WEATHER_SUCCESS) {
            List<WeatherInfo> infos;
            SAXParserFactory factory = null;
            SAXParser saxParser = null;
            XMLReader xmlReader = null;
            GetYahooWeatherSaxTools tools = null;
            try {
              factory = SAXParserFactory.newInstance();
              saxParser = factory.newSAXParser();
              xmlReader = saxParser.getXMLReader();
              infos = new ArrayList<WeatherInfo>();
              tools = new GetYahooWeatherSaxTools(infos);

              xmlReader.setContentHandler(tools);
              xmlReader.parse(new InputSource(new StringReader((String) msg.obj)));
              // 获取当前是周几,用数字表示
              int currentDay = mWeekList.indexOf(infos.get(0).getDay());
              int forecastDay = 0;
              // 将得到的list天气数据,展示到屏幕上
              for (int i = 0; i < config.getForecastDays(); i++) {
                view = View.inflate(context, R.layout.weather_item, null);
                TextView tvDay = (TextView) view.findViewById(R.id.tv_day);
                TextView tvLow = (TextView) view.findViewById(R.id.tv_temperature_low);
                TextView tvHigh = (TextView) view.findViewById(R.id.tv_temperature_high);
                TextView tvWeather = (TextView) view.findViewById(R.id.tv_weather);
                ImageView ivWeatherIcon = (ImageView) view.findViewById(R.id.iv_weather_icon);
                forecastDay = currentDay + i;
                if (forecastDay >= 7) {
                  forecastDay = forecastDay % 7;
                }
                tvDay.setText(
                    context.getResources()
                        .getStringArray(R.array.weather_day_normalform)[forecastDay]);
                tvLow.setText(infos.get(i).getLow() + mShowTypeOfTemperature[config.getShowType()]);
                tvHigh.setText(
                    infos.get(i).getHigh() + mShowTypeOfTemperature[config.getShowType()]);
                tvWeather.setText(
                    context.getResources()
                        .getStringArray(R.array.weather_condition)[infos.get(i).getCode()]);
                ivWeatherIcon.setImageResource(R.drawable.w0);

                int width = config.getWidth() / config.getForecastDays();
                int height = config.getHeight();
                float wScale = width / 100f;
                float hScale = height / 100f;
                float squarScale = width * height / (100 * 100);

                LayoutParams viewChildParams = (LayoutParams) tvDay.getLayoutParams();
                viewChildParams.height *= hScale;
                viewChildParams.width *= wScale;
                tvDay.setLayoutParams(viewChildParams);

                viewChildParams = (LayoutParams) tvLow.getLayoutParams();
                viewChildParams.height *= hScale;
                viewChildParams.width *= wScale;
                tvLow.setLayoutParams(viewChildParams);
                tvHigh.setLayoutParams(viewChildParams);

                viewChildParams = (LayoutParams) tvWeather.getLayoutParams();
                viewChildParams.height *= hScale;
                viewChildParams.width *= wScale;
                tvWeather.setLayoutParams(viewChildParams);

                viewChildParams = (LayoutParams) ivWeatherIcon.getLayoutParams();
                viewChildParams.height *= hScale;
                viewChildParams.width *= wScale;
                ivWeatherIcon.setLayoutParams(viewChildParams);

                tvDay.setTextSize(DensityUtil.dip2px(context, 14 * squarScale));
                tvLow.setTextSize(DensityUtil.dip2px(context, 14 * squarScale));
                tvHigh.setTextSize(DensityUtil.dip2px(context, 14 * squarScale));
                tvWeather.setTextSize(DensityUtil.dip2px(context, 14 * squarScale));

                LinearLayout.LayoutParams viewParams =
                    new LinearLayout.LayoutParams(
                        LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
                viewParams.weight = 1;

                mWeatherContainer.addView(view, viewParams);
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
          super.handleMessage(msg);
        }
コード例 #8
0
  private void setSheetItems() {
    if (sheetItemList == null || sheetItemList.size() <= 0) {
      return;
    }

    int size = sheetItemList.size();
    if (size >= 7) {
      LayoutParams params = (LayoutParams) sLayout_content.getLayoutParams();
      params.height = display.getHeight() / 2;
      sLayout_content.setLayoutParams(params);
    }

    for (int i = 1; i <= size; i++) {
      final int index = i;
      SheetItem sheetItem = sheetItemList.get(i - 1);
      String strItem = sheetItem.name;
      SheetItemColor color = sheetItem.color;
      final OnSheetItemClickListener listener = sheetItem.itemClickListener;
      TextView textView = new TextView(context);
      textView.setText(strItem);
      textView.setTextSize(18);
      textView.setGravity(Gravity.CENTER);
      if (size == 1) {
        if (showTitle) {
          textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector);
        } else {
          textView.setBackgroundResource(R.drawable.actionsheet_single_selector);
        }
      } else {
        if (showTitle) {
          if (i >= 1 && i < size) {
            textView.setBackgroundResource(R.drawable.actionsheet_middle_selector);
          } else {
            textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector);
          }
        } else {
          if (i == 1) {
            textView.setBackgroundResource(R.drawable.actionsheet_top_selector);
          } else if (i < size) {
            textView.setBackgroundResource(R.drawable.actionsheet_middle_selector);
          } else {
            textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector);
          }
        }
      }
      if (color == null) {
        textView.setTextColor(Color.parseColor(SheetItemColor.Blue.getName()));
      } else {
        textView.setTextColor(Color.parseColor(color.getName()));
      }
      float scale = context.getResources().getDisplayMetrics().density;
      int height = (int) (45 * scale + 0.5f);
      textView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height));
      textView.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              listener.onClick(index);
              dialog.dismiss();
            }
          });
      lLayout_content.addView(textView);
    }
  }
コード例 #9
0
ファイル: PostActivity.java プロジェクト: BGDigital/MCKuai3.0
  private void addPic(Intent data) {
    if (null != data) {
      Uri selectedImage = data.getData();
      String[] filePathColumn = {MediaStore.Images.Media.DATA};

      Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
      cursor.moveToFirst();

      int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
      String picturePath = cursor.getString(columnIndex);
      cursor.close();

      // 获取图片
      BitmapFactory.Options opts = new BitmapFactory.Options();
      opts.inJustDecodeBounds = true;
      BitmapFactory.decodeFile(picturePath, opts);
      opts.inSampleSize = computeSampleSize(opts, -1, 1080 * 700);
      opts.inJustDecodeBounds = false;
      final Bitmap bmp;
      try {
        bmp = BitmapFactory.decodeFile(picturePath, opts);
      } catch (OutOfMemoryError err) {
        showNotification(2, "图片太大!", R.id.root);
        return;
      }
      if (null == picsList) {
        picsList = new ArrayList<Bitmap>(4);
      }
      picsList.add(bmp);

      final ImageView image = new ImageView(PostActivity.this);
      LayoutParams params = (LayoutParams) btn_pic.getLayoutParams();
      params.width = btn_pic.getWidth();
      params.height = btn_pic.getHeight();
      image.setScaleType(ScaleType.CENTER_CROP);
      image.setLayoutParams(params);
      image.setImageBitmap(bmp);
      image.setClickable(true);
      image.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              if (null != mpics && mpics.getChildCount() > 0) {
                mpics.removeView(image);
                picsList.remove(bmp);
                mpics.postInvalidate();
                if (mpics.getChildCount() < 5) {
                  btn_pic.setVisibility(View.VISIBLE);
                }
                return true;
              }
              return false;
            }
          });
      int count = mpics.getChildCount();
      if (4 == count) {
        btn_pic.setVisibility(View.GONE);
      }
      mpics.addView(image, count - 1);
      mpics.postInvalidate();
    }
  }
コード例 #10
0
  /** 设置button的 宽度 以及监听 */
  private void setButton() {
    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    int width0 = 2; // 边框宽度
    int width1 = 10; // 外部边框距左右边界距离
    int hight0 = 70; // 外部边框高度
    LinearLayout a_layout = (LinearLayout) findViewById(R.id.a_layout);
    LayoutParams param = (LayoutParams) a_layout.getLayoutParams();
    param.topMargin = 10;
    param.bottomMargin = 10;
    param.leftMargin = width1;
    param.rightMargin = width1;
    if (height == 1280 && width == 720) {
      hight0 = 70;
      width = width + 4;
      param.leftMargin = width1;
      param.rightMargin = width1 + 1;
    } else if (height == 854 && width == 480) {
      hight0 = 45;
      width1 = 18;
      width0 = 2;
      param.leftMargin = width1;
      param.rightMargin = width1 - 1;
    } else if (height == 800 && width == 480) {
      hight0 = 45;
      width1 = 18;
      width0 = 2;
      param.leftMargin = width1;
      param.rightMargin = width1 - 1;
    } else if (height >= 1750 && height <= 1920 && width == 1080) {
      width1 = 40; // 外部边框距左右边界距离
      hight0 = 100;
      param.leftMargin = width1;
      param.rightMargin = width1;
    }
    int hight1 = hight0 - width0 * 2; // button高度
    param.height = hight0;
    // view1 = (Button) findViewById(R.id.view_1);
    // view2 = (Button) findViewById(R.id.view_2);
    // view3 = (Button) findViewById(R.id.view_3);
    // view1.setWidth(width0);
    // view2.setWidth(width0);
    // view3.setWidth(width0);
    // view1.setHeight(hight1);
    // view2.setHeight(hight1);
    // view3.setHeight(hight1);

    int button_width = (width - width1 * 2 - 7 * width0) / 4;
    button_1 = (Button) findViewById(R.id.button_1);
    button_2 = (Button) findViewById(R.id.button_2);
    button_3 = (Button) findViewById(R.id.button_3);
    button_4 = (Button) findViewById(R.id.button_4);
    button_1.setOnClickListener(this);
    button_2.setOnClickListener(this);
    button_3.setOnClickListener(this);
    button_4.setOnClickListener(this);
    btnList.add(button_1);
    btnList.add(button_2);
    btnList.add(button_3);
    btnList.add(button_4);

    for (int i = 0; i < btnList.size(); i++) {
      btnList.get(i).setWidth(button_width);
      btnList.get(i).setHeight(hight1);
    }

    if (version < 4) {
      button_1.setBackgroundResource(R.drawable.left_shape_red2);
      button_4.setBackgroundResource(R.drawable.right_shape_white2);
    }
  }