예제 #1
0
  public static void addActionsButton(BaseButton baseButton) {
    Drawable iconImage = mShell.getResources().getDrawable(baseButton.getButtonIconId());

    int ten_dip = (int) (10 * mShell.getResources().getDisplayMetrics().density);

    ImageView buttonIcon = new ImageView(mShell.getContext());
    buttonIcon.setImageDrawable(iconImage);
    LayoutParams iconParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    iconParams.setMargins(ten_dip, 0, 0, 0);
    iconParams.gravity = Gravity.CENTER_VERTICAL;

    TextView buttonText = new TextView(mShell.getContext());
    buttonText.setText(baseButton.getButtonText());
    buttonText.setTextColor(Color.WHITE);
    buttonText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    LayoutParams textParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    buttonText.setPadding(ten_dip, ten_dip, ten_dip, ten_dip);

    LinearLayout button = new LinearLayout(mShell.getContext());
    button.addView(buttonIcon, iconParams);
    button.addView(buttonText, textParams);

    baseButton.setActionImageView(buttonIcon);
    baseButton.setActionTextView(buttonText);

    button.setOnClickListener(baseButton.getOnClickListener());

    ActionButtonRunnable addButtonRunnable = new ActionButtonRunnable(button);
    mCurrentActivity.runOnUiThread(addButtonRunnable);
  }
예제 #2
0
    @Override
    public void run() {
      LinearLayout actionsButtons =
          (LinearLayout) mShell.findViewById(R.id.action_buttons_container);

      ImageView menuSeparator = new ImageView(mShell.getContext());
      Drawable menuSeparatorImage = mShell.getResources().getDrawable(R.drawable.ui_menu_separator);
      menuSeparator.setImageDrawable(menuSeparatorImage);
      menuSeparator.setScaleType(ScaleType.FIT_XY);
      LayoutParams separatorParams =
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

      actionsButtons.addView(mButton, actionsButtons.getChildCount());
      actionsButtons.addView(menuSeparator, separatorParams);
    }