Esempio n. 1
0
  /**
   * Adds an action button to the compatibility action bar, using menu information from a {@link
   * android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state
   * can be changed to show a loading spinner using {@link
   * com.lsn.LoadSensing.actionbar.example.android.actionbarcompat.ActionBarHelperBase#setRefreshActionItemState(boolean)}
   * .
   */
  private View addActionItemCompatFromMenuItem(final MenuItem item) {
    final int itemId = item.getItemId();

    final ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
      return null;
    }

    // Create the button
    ImageButton actionButton =
        new ImageButton(
            mActivity,
            null,
            itemId == android.R.id.home
                ? R.attr.actionbarCompatItemHomeStyle
                : R.attr.actionbarCompatItemStyle);
    actionButton.setLayoutParams(
        new ViewGroup.LayoutParams(
            (int)
                mActivity
                    .getResources()
                    .getDimension(
                        itemId == android.R.id.home
                            ? R.dimen.actionbar_compat_button_home_width
                            : R.dimen.actionbar_compat_button_width),
            ViewGroup.LayoutParams.MATCH_PARENT));

    actionButton.setImageDrawable(item.getIcon());
    actionButton.setScaleType(ImageView.ScaleType.CENTER);
    actionButton.setContentDescription(item.getTitle());

    if (itemId == R.id.menu_star) {
      actionButton.setId(R.id.actionbar_compat_item_faves);
      if (trobat) {
        actionButton.setImageResource(R.drawable.ic_action_star_on);
      } else {
        actionButton.setImageResource(R.drawable.ic_action_star_off);
      }
    }

    actionButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
          }
        });

    actionBar.addView(actionButton);

    return actionButton;
  }
  /**
   * Constructs a layout for the specified InfoBar. After calling this, be sure to set the message,
   * the buttons, and/or the custom content using setMessage(), setButtons(), and
   * setCustomContent().
   *
   * @param context The context used to render.
   * @param infoBarView InfoBarView that listens to events.
   * @param iconResourceId ID of the icon to use for the InfoBar.
   * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
   * @param message The message to show in the infobar.
   */
  public InfoBarLayout(
      Context context,
      InfoBarView infoBarView,
      int iconResourceId,
      Bitmap iconBitmap,
      CharSequence message) {
    super(context);
    mInfoBarView = infoBarView;

    // Grab the dimensions.
    Resources res = getResources();
    mMargin = res.getDimensionPixelOffset(R.dimen.infobar_margin);
    mIconSize = res.getDimensionPixelSize(R.dimen.infobar_icon_size);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(new int[] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mMargin, mMargin, mMargin, mMargin);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mMargin, -mMargin, -mMargin));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
      mIconView = new ImageView(context);
      if (iconResourceId != 0) {
        mIconView.setImageResource(iconResourceId);
      } else if (iconBitmap != null) {
        mIconView.setImageBitmap(iconBitmap);
      }
      mIconView.setLayoutParams(new LayoutParams(0, 0, mMargin / 2, 0));
      mIconView.getLayoutParams().width = mIconSize;
      mIconView.getLayoutParams().height = mIconSize;
      mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageTextView = (TextView) LayoutInflater.from(context).inflate(R.layout.infobar_text, null);
    mMessageTextView.setText(message, TextView.BufferType.SPANNABLE);
    mMessageTextView.setMovementMethod(LinkMovementMethod.getInstance());
    mMessageTextView.setLinkTextColor(mAccentColor);
    mMessageView = mMessageTextView;
  }
  private void addHelpPlaceholder(FormEntryPrompt p) {
    if (!p.hasHelp()) {
      return;
    }

    helpPlaceholder = new FrameLayout(this.getContext());
    helpPlaceholder.setLayoutParams(
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));

    ImageButton trigger = new ImageButton(getContext());
    trigger.setImageResource(android.R.drawable.ic_menu_help);
    final FormEntryPrompt prompt = p;
    trigger.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            fireHelpText(prompt);
          }
        });
    trigger.setId(847294011);
    LinearLayout triggerLayout = new LinearLayout(getContext());
    triggerLayout.setOrientation(LinearLayout.HORIZONTAL);
    triggerLayout.setLayoutParams(
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    triggerLayout.setGravity(Gravity.RIGHT);
    triggerLayout.addView(trigger);

    MediaLayout helpLayout = createHelpLayout(p);
    helpLayout.setBackgroundResource(color.very_light_blue);
    helpPlaceholder.addView(helpLayout);

    this.addView(triggerLayout);
    this.addView(helpPlaceholder);
    helpPlaceholder.setVisibility(View.GONE);
  }
Esempio n. 4
0
  private void init() {
    mCurrentDirectory = Environment.getExternalStorageDirectory();
    mInitialDirectory = Environment.getExternalStorageDirectory();

    this.setBackgroundResource(R.drawable.bg_pathbar);
    this.setInAnimation(getContext(), R.anim.fade_in);
    this.setOutAnimation(getContext(), R.anim.fade_out);

    // RelativeLayout1
    RelativeLayout standardModeLayout = new RelativeLayout(getContext());
    { // I use a block here so that layoutParams can be used as a variable name further down.
      android.widget.ViewFlipper.LayoutParams layoutParams =
          new android.widget.ViewFlipper.LayoutParams(
              LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      standardModeLayout.setLayoutParams(layoutParams);

      this.addView(standardModeLayout);
    }

    // ImageButton -- GONE. Kept this code in case we need to use an right-aligned button in the
    // future.
    mSwitchToManualModeButton = new ImageButton(getContext());
    {
      android.widget.RelativeLayout.LayoutParams layoutParams =
          new android.widget.RelativeLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

      mSwitchToManualModeButton.setLayoutParams(layoutParams);
      mSwitchToManualModeButton.setId(10);
      mSwitchToManualModeButton.setImageResource(R.drawable.ic_navbar_edit);
      mSwitchToManualModeButton.setBackgroundResource(R.drawable.bg_navbar_btn);
      mSwitchToManualModeButton.setVisibility(View.GONE);

      standardModeLayout.addView(mSwitchToManualModeButton);
    }

    // ImageButton -- GONE. Kept this code in case we need to use an left-aligned button in the
    // future.
    ImageButton cdToRootButton = new ImageButton(getContext());
    {
      android.widget.RelativeLayout.LayoutParams layoutParams =
          new android.widget.RelativeLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);

      cdToRootButton.setLayoutParams(layoutParams);
      cdToRootButton.setId(11);
      cdToRootButton.setBackgroundResource(R.drawable.bg_navbar_btn);
      cdToRootButton.setImageResource(R.drawable.ic_navbar_home);
      cdToRootButton.setScaleType(ScaleType.CENTER_INSIDE);
      cdToRootButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              cd("/");
            }
          });
      cdToRootButton.setVisibility(View.GONE);

      standardModeLayout.addView(cdToRootButton);
    }

    // Horizontal ScrollView container
    mPathButtonsContainer = new HorizontalScrollView(getContext());
    {
      android.widget.RelativeLayout.LayoutParams layoutParams =
          new android.widget.RelativeLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
      layoutParams.addRule(RelativeLayout.LEFT_OF, mSwitchToManualModeButton.getId());
      layoutParams.addRule(RelativeLayout.RIGHT_OF, cdToRootButton.getId());
      layoutParams.alignWithParent = true;

      mPathButtonsContainer.setLayoutParams(layoutParams);
      mPathButtonsContainer.setHorizontalScrollBarEnabled(false);
      mPathButtonsContainer.setHorizontalFadingEdgeEnabled(true);

      standardModeLayout.addView(mPathButtonsContainer);
    }

    // PathButtonLayout
    mPathButtons = new PathButtonLayout(getContext());
    {
      android.widget.LinearLayout.LayoutParams layoutParams =
          new android.widget.LinearLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);

      mPathButtons.setLayoutParams(layoutParams);
      mPathButtons.setNavigationBar(this);

      mPathButtonsContainer.addView(mPathButtons);
    }

    // RelativeLayout2
    RelativeLayout manualModeLayout = new RelativeLayout(getContext());
    {
      android.widget.ViewFlipper.LayoutParams layoutParams =
          new android.widget.ViewFlipper.LayoutParams(
              LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      manualModeLayout.setLayoutParams(layoutParams);

      this.addView(manualModeLayout);
    }

    // ImageButton
    mGoButton = new ImageButton(getContext());
    {
      android.widget.RelativeLayout.LayoutParams layoutParams =
          new android.widget.RelativeLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

      mGoButton.setLayoutParams(layoutParams);
      mGoButton.setId(20);
      mGoButton.setBackgroundResource(R.drawable.bg_navbar_btn);
      mGoButton.setImageResource(R.drawable.ic_navbar_accept);
      mGoButton.setScaleType(ScaleType.CENTER_INSIDE);
      mGoButton.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              manualInputCd(mPathEditText.getText().toString());
            }
          });

      manualModeLayout.addView(mGoButton);
    }

    // EditText
    mPathEditText = new EditText(getContext());
    {
      android.widget.RelativeLayout.LayoutParams layoutParams =
          new android.widget.RelativeLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      layoutParams.alignWithParent = true;
      layoutParams.addRule(RelativeLayout.LEFT_OF, mGoButton.getId());

      mPathEditText.setLayoutParams(layoutParams);
      mPathEditText.setBackgroundResource(R.drawable.bg_navbar_textfield);
      mPathEditText.setTextColor(Color.BLACK);
      mPathEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
      mPathEditText.setImeOptions(EditorInfo.IME_ACTION_GO);
      mPathEditText.setOnEditorActionListener(
          new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
              if (actionId == EditorInfo.IME_ACTION_GO
                  || (event.getAction() == KeyEvent.ACTION_DOWN
                      && (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER
                          || event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
                if (manualInputCd(v.getText().toString()))
                  // Since we have successfully navigated.
                  return true;
              }

              return false;
            }
          });

      manualModeLayout.addView(mPathEditText);
    }
  }
Esempio n. 5
0
  private void init(Context context) {
    int width = (int) context.getResources().getDimension(R.dimen.title_button_width);
    LayoutParams leftLayoutParams = new LayoutParams(width, LayoutParams.MATCH_PARENT);
    imgLeft = new ImageButton(context);
    imgLeft.setId(R.id.common_title_left_img);
    imgLeft.setPadding(padding, padding, padding, padding);
    imgLeft.setLayoutParams(leftLayoutParams);
    imgLeft.setScaleType(ScaleType.CENTER_INSIDE);
    imgLeft.setBackgroundResource(R.drawable.b_button);
    imgLeft.setOnClickListener(this);
    if (leftDrawable == null && TextUtils.isEmpty(leftText)) {
      imgLeft.setImageResource(R.drawable.backarrow);
      imgLeft.setContentDescription("Back");
    } else {
      imgLeft.setImageDrawable(leftDrawable);
    }

    LayoutParams leftLayoutParams2 =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    btnLeft = new Button(context);
    btnLeft.setId(R.id.common_title_left_txt);
    btnLeft.setTextColor(getResources().getColor(R.color.blue));
    btnLeft.setLayoutParams(leftLayoutParams2);
    btnLeft.setMinimumWidth(width);
    btnLeft.setBackgroundResource(R.drawable.b_button);
    btnLeft.setOnClickListener(this);
    if (!TextUtils.isEmpty(leftText)) {
      btnLeft.setText(leftText);
    } else {
      btnLeft.setVisibility(View.INVISIBLE);
    }

    LayoutParams rightLayoutParams = new LayoutParams(width, LayoutParams.MATCH_PARENT);
    rightLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    imgRight = new ImageButton(context);
    imgRight.setId(R.id.common_title_right_img);
    imgRight.setPadding(padding, padding, padding, padding);
    imgRight.setLayoutParams(rightLayoutParams);
    imgRight.setScaleType(ScaleType.CENTER_INSIDE);
    imgRight.setBackgroundResource(R.drawable.b_button);
    if (rightDrawable != null) {
      imgRight.setImageDrawable(rightDrawable);
    } else {
      imgRight.setVisibility(View.INVISIBLE);
    }

    LayoutParams rightLayoutParams2 =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    rightLayoutParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    btnRight = new Button(context);
    btnRight.setId(R.id.common_title_right_txt);
    btnRight.setTextColor(getResources().getColor(R.color.blue));
    btnRight.setLayoutParams(rightLayoutParams2);
    btnRight.setMinimumWidth(width);
    btnRight.setBackgroundResource(R.drawable.b_button);
    if (!TextUtils.isEmpty(rightText)) {
      btnRight.setText(rightText);
    } else {
      btnRight.setVisibility(View.INVISIBLE);
    }

    LayoutParams titleLayoutParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    titleLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    titleLayoutParams.addRule(RelativeLayout.RIGHT_OF, R.id.common_title_left_img);
    titleLayoutParams.addRule(RelativeLayout.LEFT_OF, R.id.common_title_right_img);
    txtTitle = new TextView(context);
    txtTitle.setId(R.id.common_title_title_txt);
    txtTitle.setTextSize(
        TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.font_size_large_x));
    txtTitle.setLayoutParams(titleLayoutParams);
    txtTitle.setTextColor(getResources().getColor(R.color.blue));
    txtTitle.setBackgroundColor(0x00000000);
    txtTitle.setSingleLine();
    txtTitle.setEllipsize(TruncateAt.MARQUEE);
    txtTitle.setGravity(Gravity.CENTER);
    txtTitle.setSelected(true);
    if (title == null) {
      txtTitle.setText("");
    } else {
      txtTitle.setText(title);
    }

    LayoutParams divisionLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 2);
    divisionLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    View division = new View(context);
    division.setLayoutParams(divisionLayoutParams);
    division.setBackgroundColor(getResources().getColor(R.color.gray_division));
    this.addView(imgLeft);
    this.addView(btnLeft);
    this.addView(txtTitle);
    this.addView(imgRight);
    this.addView(btnRight);
    this.addView(division);
    setBackgroundColor(0xffffffff);
  }
Esempio n. 6
0
  /**
   * Instantiates a new ab slider button.
   *
   * @param context the context
   * @param attrs the attrs
   */
  public AbSlidingButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    btnWidth = 40;
    btnHeight = 40;
    // 移动的距离
    moveWidth = 45;
    // 每次移动的距离
    movePDis = 5;
    // 覆盖按钮的宽
    WidthOffset = 5;

    WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wManager.getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();

    /*
     2 px = 3 dip if dpi == 80(ldpi), 320x240 screen
     1 px = 1 dip if dpi == 160(mdpi), 480x320 screen
     3 px = 2 dip if dpi == 240(hdpi), 840x480 screen
    */

    if (width < 320) {
      btnWidth = btnWidth - 10;
      btnHeight = btnHeight - 10;
      moveWidth = moveWidth - 10;
    } else if (width > 320 && width < 450) {
      btnWidth = btnWidth + 10;
      btnHeight = btnHeight + 10;
      moveWidth = moveWidth + 10;
    } else if (width >= 450) {
      btnWidth = btnWidth + 20;
      btnHeight = btnHeight + 20;
      moveWidth = moveWidth + 20;
    }

    detector = new GestureDetector(this);

    mRelativeLayout = new RelativeLayout(context);

    ImageButton btnOn = new ImageButton(context);
    ImageButton btnOff = new ImageButton(context);
    btnLeft = new ImageButton(context);
    btnRight = new ImageButton(context);

    btnOn.setFocusable(false);
    btnOff.setFocusable(false);
    btnLeft.setFocusable(false);
    btnRight.setFocusable(false);

    Bitmap onImage = AbFileUtil.getBitmapFormSrc("image/button_on_bg.png");
    Bitmap offImage = AbFileUtil.getBitmapFormSrc("image/button_off_bg.png");
    Bitmap blockImage = AbFileUtil.getBitmapFormSrc("image/button_block.png");

    btnOn.setId(ID_BTN1);
    // btnOn.setImageBitmap(onImage);
    btnOn.setMinimumWidth(btnWidth);
    btnOn.setMinimumHeight(btnHeight);
    btnOn.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(onImage));

    btnOff.setId(ID_BTN2);
    btnOff.setMinimumWidth(btnWidth);
    btnOff.setMinimumHeight(btnHeight);
    // btnOff.setImageBitmap(offImage);
    btnOff.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(offImage));

    btnLeft.setId(ID_BTN3);
    btnLeft.setMinimumWidth(btnWidth + WidthOffset);
    btnLeft.setMinimumHeight(btnHeight);
    // btnLeft.setImageBitmap(blockImage);
    btnLeft.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(blockImage));

    btnRight.setId(ID_BTN4);
    btnRight.setMinimumWidth(btnWidth + WidthOffset);
    btnRight.setMinimumHeight(btnHeight);
    // btnRight.setImageBitmap(blockImage);
    btnRight.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(blockImage));

    mRelativeLayout.addView(btnOn);
    mRelativeLayout.setFocusable(false);

    RelativeLayout.LayoutParams lp2 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.RIGHT_OF, ID_BTN1);
    mRelativeLayout.addView(btnOff, lp2);

    RelativeLayout.LayoutParams lp3 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp3.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    mRelativeLayout.addView(btnLeft, lp3);

    RelativeLayout.LayoutParams lp4 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    mRelativeLayout.addView(btnRight, lp4);

    addView(mRelativeLayout);

    mSwitcherChangeListener =
        new AbOnChangeListener() {

          @Override
          public void onChange(int position) {}
        };
  }
Esempio n. 7
0
  public void notifyDataSetChanged() {
    super.removeAllViews();
    layout.removeAllViews();

    if (!scrollable) { // not scrollable tabs
      int tabWidth = this.getWidth() / tabs.size();

      // set params for resizing tabs width
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(tabWidth, HorizontalScrollView.LayoutParams.MATCH_PARENT);
      for (MaterialTab t : tabs) {
        layout.addView(t.getView(), params);
      }

    } else { // scrollable tabs

      if (!isTablet) {
        for (int i = 0; i < tabs.size(); i++) {
          LinearLayout.LayoutParams params;
          MaterialTab tab = tabs.get(i);

          int tabWidth = (int) (tab.getTabMinWidth() + (24 * density)); // 12dp
          // +
          // text/icon
          // width
          // +
          // 12dp

          if (i == 0) {
            // first tab
            View view = new View(layout.getContext());
            view.setMinimumWidth((int) (60 * density));
            layout.addView(view);
          }

          params =
              new LinearLayout.LayoutParams(
                  tabWidth, HorizontalScrollView.LayoutParams.MATCH_PARENT);
          layout.addView(tab.getView(), params);

          if (i == tabs.size() - 1) {
            // last tab
            View view = new View(layout.getContext());
            view.setMinimumWidth((int) (60 * density));
            layout.addView(view);
          }
        }
      } else {
        // is a tablet
        for (int i = 0; i < tabs.size(); i++) {
          LinearLayout.LayoutParams params;
          MaterialTab tab = tabs.get(i);

          int tabWidth = (int) (tab.getTabMinWidth() + (48 * density)); // 24dp
          // +
          // text/icon
          // width
          // +
          // 24dp

          params =
              new LinearLayout.LayoutParams(
                  tabWidth, HorizontalScrollView.LayoutParams.MATCH_PARENT);
          layout.addView(tab.getView(), params);
        }
      }
    }

    if (isTablet && scrollable) {
      // if device is a tablet and have scrollable tabs add right and left
      // arrows
      Resources res = getResources();

      left = new ImageButton(this.getContext());
      left.setId(R.id.left);
      left.setImageDrawable(res.getDrawable(R.drawable.left_arrow));
      left.setBackgroundColor(Color.TRANSPARENT);
      left.setOnClickListener(this);

      // set 56 dp width and 48 dp height
      RelativeLayout.LayoutParams paramsLeft =
          new LayoutParams((int) (56 * density), (int) (48 * density));
      paramsLeft.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      paramsLeft.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      paramsLeft.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      this.addView(left, paramsLeft);

      right = new ImageButton(this.getContext());
      right.setId(R.id.right);
      right.setImageDrawable(res.getDrawable(R.drawable.right_arrow));
      right.setBackgroundColor(Color.TRANSPARENT);
      right.setOnClickListener(this);

      RelativeLayout.LayoutParams paramsRight =
          new LayoutParams((int) (56 * density), (int) (48 * density));
      paramsRight.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      paramsRight.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      paramsRight.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      this.addView(right, paramsRight);

      RelativeLayout.LayoutParams paramsScroll =
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      paramsScroll.addRule(RelativeLayout.LEFT_OF, R.id.right);
      paramsScroll.addRule(RelativeLayout.RIGHT_OF, R.id.left);
      this.addView(scrollView, paramsScroll);
    } else {
      // if is not a tablet add only scrollable content
      RelativeLayout.LayoutParams paramsScroll =
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      this.addView(scrollView, paramsScroll);
    }

    this.setSelectedNavigationItem(tabSelected);
  }
Esempio n. 8
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   try { // try to get matrix config
     String fname = "battleship";
     File file = getBaseContext().getFileStreamPath(fname);
     if (file.exists()) { // read from file
       DataInputStream in = new DataInputStream(openFileInput(fname));
       for (int i = 0; i < 10; i++) {
         for (int j = 0; j < 10; j++) {
           P1[i][j] = Integer.parseInt(in.readUTF());
         }
       }
       for (int i = 0; i < 10; i++) {
         for (int j = 0; j < 10; j++) {
           P2[i][j] = Integer.parseInt(in.readUTF());
         }
       }
       in.close();
     }
   } catch (IOException e) {
     Log.i("Data Input Sample", "I/O Error");
   }
   RelativeLayout hugelay = new RelativeLayout(this);
   ScrollView largelay = new ScrollView(this);
   largelay.setId(10000);
   TableLayout layout = new TableLayout(this);
   layout.setLayoutParams(new TableLayout.LayoutParams(300, 300));
   layout.setPadding(1, 1, 1, 1);
   int i, j;
   for (i = 0; i <= 9; i++) {
     TableRow tr = new TableRow(this);
     for (j = 0; j <= 9; j++) {
       ImageButton b = new ImageButton(this);
       if (P2[i][j] == 0) {
         b.setImageResource(R.drawable.water);
       } else if (P2[i][j] == 99) {
         b.setImageResource(R.drawable.explosion);
       } else if (P2[i][j] == 88) {
         b.setImageResource(R.drawable.x);
       } else {
         b.setImageResource(R.drawable.water2);
       }
       b.setId(i * 10 + j);
       b.setOnClickListener(this);
       tr.addView(b, 72, 72);
     } // for
     layout.addView(tr);
   } // for
   largelay.addView(layout);
   hugelay.setBackgroundResource(R.drawable.battleshipbg);
   Button btn = new Button(this);
   btn.setText("MY MAP");
   btn.setBackgroundResource(R.color.transparent);
   btn.setHeight(134);
   btn.setWidth(134);
   btn.setId(1000);
   btn.setOnClickListener(this);
   RelativeLayout.LayoutParams lp =
       new RelativeLayout.LayoutParams(
           RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   lp.addRule(RelativeLayout.RIGHT_OF, largelay.getId());
   lp.addRule(RelativeLayout.CENTER_VERTICAL);
   hugelay.addView(largelay);
   hugelay.addView(btn, lp);
   super.setContentView(hugelay);
 } // ()
  @Override
  public void createControl(TitaniumModuleManager tmm) {
    tv = new EditText(tmm.getAppContext());
    tv.isFocusable();
    tv.setId(100);

    tv.addTextChangedListener(this);
    tv.setOnEditorActionListener(this);
    tv.setText(value);
    tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    tv.setPadding(4, 2, 4, 2);
    tv.setSingleLine();
    TitaniumUIHelper.styleText(tv, fontSize, fontWeight);

    if (color != null) {
      tv.setTextColor(TitaniumColorHelper.parseColor(color));
    }
    if (backgroundColor != null) {
      tv.setBackgroundColor(TitaniumColorHelper.parseColor(backgroundColor));
    }

    cancelBtn = new ImageButton(tmm.getAppContext());
    cancelBtn.isFocusable();
    cancelBtn.setId(101);
    cancelBtn.setPadding(0, 0, 0, 0);
    Drawable d = new BitmapDrawable(this.getClass().getResourceAsStream("cancel.png"));
    cancelBtn.setImageDrawable(d);
    cancelBtn.setMinimumWidth(48);

    cancelBtn.setVisibility(showCancel ? View.VISIBLE : View.GONE);
    cancelBtn.setOnClickListener(
        new OnClickListener() {

          public void onClick(View view) {
            handler.sendEmptyMessage(MSG_CANCEL);
          }
        });

    RelativeLayout layout = new RelativeLayout(tmm.getAppContext());
    control = layout;

    layout.setGravity(Gravity.NO_GRAVITY);
    layout.setPadding(0, 0, 0, 0);
    if (barColor != null) {
      layout.setBackgroundColor(TitaniumColorHelper.parseColor(barColor));
    }

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.addRule(RelativeLayout.LEFT_OF, 101);
    params.setMargins(4, 4, 0, 4);
    layout.addView(tv, params);

    params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    params.setMargins(0, 4, 4, 4);
    layout.addView(cancelBtn, params);
  }
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    mContext = getApplicationContext();
    mApp = (Common) getApplicationContext();
    mApp.setNowPlayingActivity(this);
    setNowPlayingActivityListener(mApp.getPlaybackKickstarter());

    // Set the UI theme.
    setTheme();

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_now_playing);

    // Set the volume stream for this activity.
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Drawer layout.
    if (!mApp.isTabletInLandscape()) {
      mDrawerLayout = (DrawerLayout) findViewById(R.id.main_activity_drawer_root);
      mDrawerParentLayout = (FrameLayout) findViewById(R.id.now_playing_drawer_frame_root);
      mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
      mDrawerLayout.setDrawerListener(mDrawerListener);
      mDrawerLayout.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    } else {
      mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
    }

    // ViewPager.
    mViewPager = (VelocityViewPager) findViewById(R.id.nowPlayingPlaylistPager);

    // Seekbar indicator.
    mSeekbarIndicatorLayoutParent = (RelativeLayout) findViewById(R.id.seekbarIndicatorParent);
    mSeekbarIndicatorLayout = (RelativeLayout) findViewById(R.id.seekbarIndicator);
    mSeekbarIndicatorText = (TextView) findViewById(R.id.seekbarIndicatorText);

    mSeekbarIndicatorLayoutParent.setVisibility(View.GONE);
    mSeekbarIndicatorLayout.setBackgroundResource(
        UIElementsHelper.getGridViewCardBackground(mContext));
    mSeekbarIndicatorText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    mSeekbarIndicatorText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext));

    // Playback Controls.
    mControlsLayoutHeaderParent =
        (RelativeLayout) findViewById(R.id.now_playing_controls_header_parent);
    mControlsLayoutHeader = (RelativeLayout) findViewById(R.id.now_playing_controls_header);
    mPlayPauseButtonBackground = (RelativeLayout) findViewById(R.id.playPauseButtonBackground);
    mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton);
    mNextButton = (ImageButton) findViewById(R.id.nextButton);
    mPreviousButton = (ImageButton) findViewById(R.id.previousButton);
    mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton);
    mRepeatButton = (ImageButton) findViewById(R.id.repeatButton);

    // Song info/seekbar elements.
    mSeekbar = (SeekBar) findViewById(R.id.nowPlayingSeekBar);
    mStreamingProgressBar = (ProgressBar) findViewById(R.id.startingStreamProgressBar);
    mStreamingProgressBar.setVisibility(View.GONE);

    try {
      mSeekbar.setThumb(getResources().getDrawable(R.drawable.transparent_drawable));
    } catch (Exception e) {
      e.printStackTrace();
    }

    mPlayPauseButtonBackground.setBackgroundResource(UIElementsHelper.getShadowedCircle(mContext));
    mPlayPauseButton.setImageResource(R.drawable.pause_light);
    mPlayPauseButton.setId(R.drawable.pause_light);
    mNextButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_next"));
    mPreviousButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_previous"));

    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
      mNextButton.setAlpha(1f);
      mPreviousButton.setAlpha(1f);
    }

    // KitKat specific layout code.
    setKitKatTranslucentBars();

    // Set the control buttons and background.
    setControlButtonsBackground();
    setPlayPauseButton();
    setShuffleButtonIcon();
    setRepeatButtonIcon();

    // Set the click listeners.
    mSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
    mNextButton.setOnClickListener(mOnClickNextListener);
    mPreviousButton.setOnClickListener(mOnClickPreviousListener);
    mPlayPauseButton.setOnClickListener(playPauseClickListener);
    mPlayPauseButtonBackground.setOnClickListener(playPauseClickListener);
    mShuffleButton.setOnClickListener(shuffleButtonClickListener);
    mRepeatButton.setOnClickListener(repeatButtonClickListener);

    // Apply haptic feedback to the play/pause button.
    mPlayPauseButtonBackground.setHapticFeedbackEnabled(true);
    mPlayPauseButton.setHapticFeedbackEnabled(true);
  }
  /**
   * Adds an action button to the compatibility action bar, using menu information from a {@link
   * android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state
   * can be changed to show a loading spinner using {@link
   * com.example.android.actionbarcompat.ActionBarHelperBase#setRefreshActionItemState(boolean)}.
   */
  private View addActionItemCompatFromMenuItem(final MenuItem item) {
    final int itemId = item.getItemId();

    final ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
      return null;
    }

    // Create the button
    ImageButton actionButton =
        new ImageButton(
            mActivity,
            null,
            itemId == android.R.id.home
                ? R.attr.actionbarCompatItemHomeStyle
                : R.attr.actionbarCompatItemStyle);
    actionButton.setLayoutParams(
        new ViewGroup.LayoutParams(
            (int)
                mActivity
                    .getResources()
                    .getDimension(
                        itemId == android.R.id.home
                            ? R.dimen.actionbar_compat_button_home_width
                            : R.dimen.actionbar_compat_button_width),
            ViewGroup.LayoutParams.FILL_PARENT));
    if (itemId == R.id.menu_refresh) {
      actionButton.setId(R.id.actionbar_compat_item_refresh);
    }
    actionButton.setImageDrawable(item.getIcon());
    actionButton.setScaleType(ImageView.ScaleType.CENTER);
    actionButton.setContentDescription(item.getTitle());
    actionButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
          }
        });

    actionBar.addView(actionButton);

    if (item.getItemId() == R.id.menu_refresh) {
      // Refresh buttons should be stateful, and allow for indeterminate progress indicators,
      // so add those.
      ProgressBar indicator =
          new ProgressBar(mActivity, null, R.attr.actionbarCompatProgressIndicatorStyle);

      final int buttonWidth =
          mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_button_width);
      final int buttonHeight =
          mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height);
      final int progressIndicatorWidth = buttonWidth / 2;

      LinearLayout.LayoutParams indicatorLayoutParams =
          new LinearLayout.LayoutParams(progressIndicatorWidth, progressIndicatorWidth);
      indicatorLayoutParams.setMargins(
          (buttonWidth - progressIndicatorWidth) / 2,
          (buttonHeight - progressIndicatorWidth) / 2,
          (buttonWidth - progressIndicatorWidth) / 2,
          0);
      indicator.setLayoutParams(indicatorLayoutParams);
      indicator.setVisibility(View.GONE);
      indicator.setId(R.id.actionbar_compat_item_refresh_progress);
      actionBar.addView(indicator);
    }

    return actionButton;
  }
Esempio n. 12
0
    public void setAVT(FormIndex index, String selectionDesignator, TextView text, String audioURI, String imageURI, String videoURI,
            final String bigImageURI) {
    	mSelectionDesignator = selectionDesignator;
    	mIndex = index;
        mView_Text = text;
        mView_Text.setId(QuestionWidget.newUniqueId());
        mVideoURI = videoURI;

        // Layout configurations for our elements in the relative layout
        RelativeLayout.LayoutParams textParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        RelativeLayout.LayoutParams audioParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        RelativeLayout.LayoutParams imageParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        RelativeLayout.LayoutParams videoParams =
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        // First set up the audio button
        if (audioURI != null) {
            // An audio file is specified
            mAudioButton = new AudioButton(getContext(), mIndex, mSelectionDesignator, audioURI);
            mAudioButton.setId(QuestionWidget.newUniqueId()); // random ID to be used by the
                                                                      // relative layout.
        } else {
            // No audio file specified, so ignore.
        }

        // Then set up the video button
        if (videoURI != null) {
            // An video file is specified
            mVideoButton = new ImageButton(getContext());
            Bitmap b =
                    BitmapFactory.decodeResource(getContext().getResources(),
                        android.R.drawable.ic_media_play);
            mVideoButton.setImageBitmap(b);
            mVideoButton.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                	Collect.getInstance().getActivityLogger().logInstanceAction(this, "onClick", "playVideoPrompt"+mSelectionDesignator, mIndex);
                	MediaLayout.this.playVideo();
                }

            });
            mVideoButton.setId(QuestionWidget.newUniqueId());
        } else {
            // No video file specified, so ignore.
        }

        // Now set up the image view
        String errorMsg = null;
        final int imageId = QuestionWidget.newUniqueId();
        if (imageURI != null) {
            try {
                String imageFilename = ReferenceManager._().DeriveReference(imageURI).getLocalURI();
                final File imageFile = new File(imageFilename);
                if (imageFile.exists()) {
                    Display display =
                        ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                                .getDefaultDisplay();
                    int screenWidth = display.getWidth();
                    int screenHeight = display.getHeight();
                    Bitmap b = FileUtils.getBitmapScaledToDisplay(imageFile, screenHeight, screenWidth);
                    if (b != null) {
                        mImageView = new ImageView(getContext());
                        mImageView.setPadding(2, 2, 2, 2);
                        mImageView.setBackgroundColor(Color.WHITE);
                        mImageView.setImageBitmap(b);
                        mImageView.setId(imageId);

                        if (bigImageURI != null) {
                            mImageView.setOnClickListener(new OnClickListener() {
                            	String bigImageFilename = ReferenceManager._()
                                        .DeriveReference(bigImageURI).getLocalURI();
                                File bigImage = new File(bigImageFilename);


                                @Override
                                public void onClick(View v) {
                                	Collect.getInstance().getActivityLogger().logInstanceAction(this, "onClick", "showImagePromptBigImage"+mSelectionDesignator, mIndex);

                                    Intent i = new Intent("android.intent.action.VIEW");
                                    i.setDataAndType(Uri.fromFile(bigImage), "image/*");
                                    try {
                                        getContext().startActivity(i);
                                    } catch (ActivityNotFoundException e) {
                                        Toast.makeText(
                                            getContext(),
                                            getContext().getString(R.string.activity_not_found,
                                                "view image"), Toast.LENGTH_SHORT).show();
                                    }
                                }
                            });
                        }
                    } else {
                        // Loading the image failed, so it's likely a bad file.
                        errorMsg = getContext().getString(R.string.file_invalid, imageFile);
                    }
                } else {
                    // We should have an image, but the file doesn't exist.
                    errorMsg = getContext().getString(R.string.file_missing, imageFile);
                }

                if (errorMsg != null) {
                    // errorMsg is only set when an error has occurred
                    Log.e(t, errorMsg);
                    mMissingImage = new TextView(getContext());
                    mMissingImage.setText(errorMsg);
                    mMissingImage.setPadding(10, 10, 10, 10);
                    mMissingImage.setId(imageId);
                }
            } catch (InvalidReferenceException e) {
                Log.e(t, "image invalid reference exception");
                e.printStackTrace();
            }
        } else {
            // There's no imageURI listed, so just ignore it.
        }

        // e.g., for TextView that flag will be true
        boolean isNotAMultipleChoiceField = !RadioButton.class.isAssignableFrom(text.getClass()) && !CheckBox.class.isAssignableFrom(text.getClass());

        // Determine the layout constraints...
        // Assumes LTR, TTB reading bias!
        if (mView_Text.getText().length() == 0 && (mImageView != null || mMissingImage != null)) {
            // No text; has image. The image is treated as question/choice icon.
            // The Text view may just have a radio button or checkbox. It
            // needs to remain in the layout even though it is blank.
            //
            // The image view, as created above, will dynamically resize and
            // center itself. We want it to resize but left-align itself
            // in the resized area and we want a white background, as otherwise
            // it will show a grey bar to the right of the image icon.
            if (mImageView != null) {
                mImageView.setScaleType(ScaleType.FIT_START);
            }
            //
            // In this case, we have:
            // Text upper left; image upper, left edge aligned with text right edge;
            // audio upper right; video below audio on right.
            textParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            textParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            if (isNotAMultipleChoiceField) {
                imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
            } else {
                imageParams.addRule(RelativeLayout.RIGHT_OF, mView_Text.getId());
            }
            imageParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            if (mAudioButton != null && mVideoButton == null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                imageParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
            } else if (mAudioButton == null && mVideoButton != null) {
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                imageParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
            } else if (mAudioButton != null && mVideoButton != null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                imageParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                videoParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
                imageParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
            } else {
                // the image will implicitly scale down to fit within parent...
                // no need to bound it by the width of the parent...
                if (!isNotAMultipleChoiceField) {
                    imageParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                }
            }
            imageParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        } else {
            // We have a non-blank text label -- image is below the text.
            // In this case, we want the image to be centered...
            if (mImageView != null) {
                mImageView.setScaleType(ScaleType.FIT_START);
            }
            //
            // Text upper left; audio upper right; video below audio on right.
            // image below text, audio and video buttons; left-aligned with text.
            textParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            textParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            if (mAudioButton != null && mVideoButton == null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                textParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
          } else if (mAudioButton == null && mVideoButton != null) {
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                textParams.addRule(RelativeLayout.LEFT_OF, mVideoButton.getId());
            } else if (mAudioButton != null && mVideoButton != null) {
                audioParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                textParams.addRule(RelativeLayout.LEFT_OF, mAudioButton.getId());
                videoParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                videoParams.addRule(RelativeLayout.BELOW, mAudioButton.getId());
            } else {
                textParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            }

            if (mImageView != null || mMissingImage != null) {
                imageParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
                imageParams.addRule(RelativeLayout.BELOW, mView_Text.getId());
            } else {
                textParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            }
        }

        addView(mView_Text, textParams);
        if (mAudioButton != null)
            addView(mAudioButton, audioParams);
        if (mVideoButton != null)
            addView(mVideoButton, videoParams);
        if (mImageView != null)
            addView(mImageView, imageParams);
        else if (mMissingImage != null)
            addView(mMissingImage, imageParams);
    }