Beispiel #1
0
  @SuppressWarnings("deprecation")
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.select);
    official = (ImageButton) findViewById(R.id.official);
    // official.setBackground(null);
    people = (ImageButton) findViewById(R.id.people);
    people.setBackgroundDrawable(null);
    // people.setBackground(null);
    official.setBackgroundDrawable(null);
    official.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            intent.setClass(getApplicationContext(), FireEntry.class);
            startActivity(intent);
            finish();
          }
        });
    official.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == MotionEvent.ACTION_DOWN) // 按下的時候改變背景及顏色
            official.setImageResource(R.drawable.firefighter_button_down);
            else official.setImageResource(R.drawable.firefighter_button);
            return false;
          }
        });
    people.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            intent.setClass(getApplicationContext(), VolunteerEntry.class);
            startActivity(intent);
            finish();
          }
        });
    people.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == MotionEvent.ACTION_DOWN) // 按下的時候改變背景及顏色
            people.setImageResource(R.drawable.user_button_down);
            else people.setImageResource(R.drawable.user_button);
            return false;
          }
        });
  }
 private void setThumbnail(int position, ImageButton dishPic, FileInputStream inStream) {
   Bitmap photo = BitmapFactory.decodeStream(inStream);
   Drawable drawable = new BitmapDrawable(photo);
   dishPic.setTag(position);
   dishPic.setBackgroundDrawable(drawable);
   dishPic.setOnClickListener(thumbnailClicked);
 }
Beispiel #3
0
  /** Sets Buttons visibility */
  @SuppressWarnings("deprecation")
  @SuppressLint("NewApi")
  protected void setupButtons() {

    if (mCardHeader.isButtonOverflowVisible()) {
      visibilityButtonHelper(VISIBLE, GONE, GONE);
      // Add popup
      addPopup();
    } else {

      if (mCardHeader.isButtonExpandVisible()) {
        visibilityButtonHelper(GONE, VISIBLE, GONE);
      } else {

        if (mCardHeader.isOtherButtonVisible() && mImageButtonOther != null) {
          visibilityButtonHelper(GONE, GONE, VISIBLE);
          // Check if button is not null
          if (mImageButtonOther != null) {
            if (mCardHeader.getOtherButtonDrawable() > 0) {
              if (Build.VERSION.SDK_INT >= 16) {
                mImageButtonOther.setBackground(
                    getResources().getDrawable(mCardHeader.getOtherButtonDrawable()));
              } else {
                mImageButtonOther.setBackgroundDrawable(
                    getResources().getDrawable(mCardHeader.getOtherButtonDrawable()));
              }
            }
            addOtherListener();
          }
        } else {
          visibilityButtonHelper(GONE, GONE, GONE);
        }
      }
    }
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.main, menu);

    getSupportActionBar().setDisplayShowHomeEnabled(true);
    // ActionBar Layout Backgroung color changing GREEN == Ramesh Gundala
    com.actionbarsherlock.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar));
    ImageButton b = new ImageButton(getApplicationContext());
    b.setBackgroundDrawable(null);
    b.setImageDrawable(getResources().getDrawable(R.drawable.buttondone));

    b.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(getApplicationContext(), MortgageNegotiatorActivity_.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
          }
        });

    menu.findItem(R.id.btnDone).setActionView(b);
    menu.findItem(R.id.github).setVisible(false);
    menu.findItem(R.id.btnDone).setVisible(true);
    return true;
  }
 private void refreshButtonBackground(ImageButton ib, File associatedFile) {
   if (associatedFile.exists()) {
     if (associatedFile.getName().endsWith(".png")) {
       Drawable d = Drawable.createFromPath(associatedFile.getAbsolutePath());
       ib.setBackgroundDrawable(d);
     } else if (associatedFile.getName().endsWith(".3gpp"))
       ib.setBackgroundResource(R.drawable.microphone_blue);
   }
 }
  @SuppressWarnings("deprecation")
  private void disableButtons() {
    mLoadButtonContainer.setEnabled(false);
    mLoadImageButton.setEnabled(false);

    mPurgeButtonContainer.setEnabled(false);
    mPurgeImageButton.setEnabled(false);

    mLoadButtonContainer.setBackgroundDrawable(
        getResources().getDrawable(R.drawable.curve_border_disabled_button));
    mPurgeButtonContainer.setBackgroundDrawable(
        getResources().getDrawable(R.drawable.curve_border_disabled_button));

    mLoadImageButton.setBackgroundDrawable(
        getResources().getDrawable(R.drawable.left_border_disabled_part_of_button));
    mPurgeImageButton.setBackgroundDrawable(
        getResources().getDrawable(R.drawable.left_border_disabled_part_of_button));
  }
 void setPic(int position, String picPath) {
   FileInputStream inStream = getThumbnail(picPath);
   if (inStream != null) {
     setThumbnail(position, dishPic, inStream);
   } else {
     Resources resources = MenuActivity.this.getResources();
     dishPic.setBackgroundDrawable(resources.getDrawable(R.drawable.no_pic_bigl));
     dishPic.setOnClickListener(null);
   }
 }
  @SuppressWarnings("deprecation")
  private void setKeyStowDrawableAndVisibility() {
    Drawable replacer = null;
    if (layoutKeys.getVisibility() == View.GONE)
      replacer = getResources().getDrawable(R.drawable.showkeys);
    else replacer = getResources().getDrawable(R.drawable.hidekeys);

    int sdk = android.os.Build.VERSION.SDK_INT;
    if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
      keyStow.setBackgroundDrawable(replacer);
    } else {
      keyStow.setBackground(replacer);
    }

    if (connection.getExtraKeysToggleType() == Constants.EXTRA_KEYS_OFF)
      keyStow.setVisibility(View.GONE);
    else keyStow.setVisibility(View.VISIBLE);
  }
  private void createInterstitialCloseButton() {
    mCloseButton = new ImageButton(getContext());
    StateListDrawable states = new StateListDrawable();
    states.addState(
        new int[] {-android.R.attr.state_pressed},
        INTERSTITIAL_CLOSE_BUTTON_NORMAL.decodeImage(getContext()));
    states.addState(
        new int[] {android.R.attr.state_pressed},
        INTERSTITIAL_CLOSE_BUTTON_PRESSED.decodeImage(getContext()));
    mCloseButton.setImageDrawable(states);
    mCloseButton.setBackgroundDrawable(null);
    mCloseButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            getBaseVideoViewControllerListener().onFinish();
          }
        });

    RelativeLayout.LayoutParams buttonLayout =
        new RelativeLayout.LayoutParams(mButtonSize, mButtonSize);
    buttonLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    buttonLayout.setMargins(mButtonPadding, 0, mButtonPadding, 0);
    getLayout().addView(mCloseButton, buttonLayout);
  }
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.fragment_moviedetail, container, false);
    if (VersionUtils.isJellyBean() && container != null) {
      mRoot.setMinimumHeight(container.getMinimumHeight());
    }
    ButterKnife.inject(this, mRoot);

    if (!VersionUtils.isJellyBean()) {
      mPlayButton.setBackgroundDrawable(
          PixelUtils.changeDrawableColor(
              mPlayButton.getContext(), R.drawable.play_button_circle, sMovie.color));
    } else {
      mPlayButton.setBackground(
          PixelUtils.changeDrawableColor(
              mPlayButton.getContext(), R.drawable.play_button_circle, sMovie.color));
    }

    mTitle.setText(sMovie.title);
    if (!sMovie.rating.equals("-1")) {
      Double rating = Double.parseDouble(sMovie.rating);
      mRating.setProgress(rating.intValue());
      mRating.setVisibility(View.VISIBLE);
    } else {
      mRating.setVisibility(View.GONE);
    }

    String metaDataStr = sMovie.year;
    if (!TextUtils.isEmpty(sMovie.runtime)) {
      metaDataStr += " • ";
      metaDataStr += sMovie.runtime + " " + getString(R.string.minutes);
    }

    if (!TextUtils.isEmpty(sMovie.genre)) {
      metaDataStr += " • ";
      metaDataStr += sMovie.genre;
    }

    mMeta.setText(metaDataStr);

    if (!TextUtils.isEmpty(sMovie.synopsis)) {
      mSynopsis.setText(sMovie.synopsis);
      mSynopsis.post(
          new Runnable() {
            @Override
            public void run() {
              boolean ellipsized = false;
              Layout layout = mSynopsis.getLayout();
              if (layout == null) return;
              int lines = layout.getLineCount();
              if (lines > 0) {
                int ellipsisCount = layout.getEllipsisCount(lines - 1);
                if (ellipsisCount > 0) {
                  ellipsized = true;
                }
              }
              mReadMore.setVisibility(ellipsized ? View.VISIBLE : View.GONE);
            }
          });
    } else {
      mSynopsis.setClickable(false);
      mReadMore.setVisibility(View.GONE);
    }

    mWatchTrailer.setVisibility(
        sMovie.trailer == null || sMovie.trailer.isEmpty() ? View.GONE : View.VISIBLE);

    mSubtitles.setFragmentManager(getFragmentManager());
    mQuality.setFragmentManager(getFragmentManager());
    mSubtitles.setTitle(R.string.subtitles);
    mQuality.setTitle(R.string.quality);

    mSubtitles.setText(R.string.loading_subs);
    mSubtitles.setClickable(false);

    if (sMovie.getSubsProvider() != null) {
      sMovie
          .getSubsProvider()
          .getList(
              sMovie,
              new SubsProvider.Callback() {
                @Override
                public void onSuccess(Map<String, String> subtitles) {
                  if (!mAttached) return;

                  if (subtitles == null) {
                    ThreadUtils.runOnUiThread(
                        new Runnable() {
                          @Override
                          public void run() {
                            mSubtitles.setText(R.string.no_subs_available);
                          }
                        });
                    return;
                  }

                  sMovie.subtitles = subtitles;

                  String[] languages = subtitles.keySet().toArray(new String[subtitles.size()]);
                  Arrays.sort(languages);
                  final String[] adapterLanguages = new String[languages.length + 1];
                  adapterLanguages[0] = "no-subs";
                  System.arraycopy(languages, 0, adapterLanguages, 1, languages.length);

                  String[] readableNames = new String[adapterLanguages.length];
                  for (int i = 0; i < readableNames.length; i++) {
                    String language = adapterLanguages[i];
                    if (language.equals("no-subs")) {
                      readableNames[i] = getString(R.string.no_subs);
                    } else {
                      Locale locale = LocaleUtils.toLocale(language);
                      readableNames[i] = locale.getDisplayName(locale);
                    }
                  }

                  mSubtitles.setListener(
                      new OptionSelector.SelectorListener() {
                        @Override
                        public void onSelectionChanged(int position, String value) {
                          onSubtitleLanguageSelected(adapterLanguages[position]);
                        }
                      });
                  mSubtitles.setData(readableNames);
                  ThreadUtils.runOnUiThread(
                      new Runnable() {
                        @Override
                        public void run() {
                          mSubtitles.setClickable(true);
                        }
                      });

                  String defaultSubtitle =
                      PrefUtils.get(mSubtitles.getContext(), Prefs.SUBTITLE_DEFAULT, null);
                  if (subtitles.containsKey(defaultSubtitle)) {
                    onSubtitleLanguageSelected(defaultSubtitle);
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf(defaultSubtitle));
                  } else {
                    onSubtitleLanguageSelected("no-subs");
                    mSubtitles.setDefault(Arrays.asList(adapterLanguages).indexOf("no-subs"));
                  }
                }

                @Override
                public void onFailure(Exception e) {
                  mSubtitles.setData(new String[0]);
                  mSubtitles.setClickable(true);
                }
              });
    } else {
      mSubtitles.setClickable(false);
      mSubtitles.setText(R.string.no_subs_available);
    }

    if (sMovie.torrents.size() > 0) {
      final String[] qualities =
          sMovie.torrents.keySet().toArray(new String[sMovie.torrents.size()]);
      SortUtils.sortQualities(qualities);
      mQuality.setData(qualities);
      mQuality.setListener(
          new OptionSelector.SelectorListener() {
            @Override
            public void onSelectionChanged(int position, String value) {
              mSelectedQuality = value;
              renderHealth();
              updateMagnet();
            }
          });
      String defaultQuality = PrefUtils.get(mQuality.getContext(), Prefs.QUALITY_DEFAULT, "720p");
      int qualityIndex =
          Arrays.asList(qualities).contains(defaultQuality)
              ? Arrays.asList(qualities).indexOf(defaultQuality)
              : qualities.length - 1;
      mSelectedQuality = qualities[qualityIndex];
      mQuality.setText(mSelectedQuality);
      mQuality.setDefault(qualityIndex);
      renderHealth();
      updateMagnet();
    }

    if (mCoverImage != null) {
      Picasso.with(mCoverImage.getContext()).load(sMovie.image).into(mCoverImage);
    }

    return mRoot;
  }
Beispiel #11
0
  /** Setup the layout graphical items based on the current theme. */
  private void setupLayoutTheme() {
    if (_debug) Log.v("ThemeView.setupLayoutTheme() _themePackageName: " + _themePackageName);
    Drawable layoutBackgroundDrawable = null;
    Drawable rescheduleDrawable = null;
    Drawable ttsDrawable = null;
    int notificationCountTextColorID = 0;
    int headerInfoTextcolorID = 0;
    int contactNameTextColorID = 0;
    int contactNumberTextColorID = 0;
    int bodyTextColorID = 0;
    int buttonTextColorID = 0;
    String themeName = null;
    if (_themePackageName.startsWith(Constants.DARK_TRANSLUCENT_THEME)) {
      _resources = _context.getResources();
      if (_themePackageName.equals(Constants.DARK_TRANSLUCENT_THEME)) {
        layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel);
        themeName =
            _context.getString(R.string.notify_theme)
                + " - "
                + _context.getString(R.string.default_v1);
      } else if (_themePackageName.equals(Constants.DARK_TRANSLUCENT_V2_THEME)) {
        layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel_v2);
        themeName =
            _context.getString(R.string.notify_theme)
                + " - "
                + _context.getString(R.string.default_v2);
      } else if (_themePackageName.equals(Constants.DARK_TRANSLUCENT_V3_THEME)) {
        layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel_v3);
        themeName =
            _context.getString(R.string.notify_theme)
                + " - "
                + _context.getString(R.string.default_v3);
      }
      rescheduleDrawable = _resources.getDrawable(R.drawable.ic_reschedule);
      ttsDrawable = _resources.getDrawable(R.drawable.ic_tts);
      notificationCountTextColorID = _resources.getColor(R.color.notification_count_text_color);
      headerInfoTextcolorID = _resources.getColor(R.color.header_info_text_color);
      contactNameTextColorID = _resources.getColor(R.color.contact_name_text_color);
      contactNumberTextColorID = _resources.getColor(R.color.contact_number_text_color);
      bodyTextColorID = _resources.getColor(R.color.body_text_color);
      buttonTextColorID = _resources.getColor(R.color.button_text_color);
    } else {
      try {
        _resources = _context.getPackageManager().getResourcesForApplication(_themePackageName);
        layoutBackgroundDrawable =
            _resources.getDrawable(
                _resources.getIdentifier(
                    _themePackageName + ":drawable/background_panel", null, null));
        rescheduleDrawable =
            _resources.getDrawable(
                _resources.getIdentifier(
                    _themePackageName + ":drawable/ic_reschedule", null, null));
        ttsDrawable =
            _resources.getDrawable(
                _resources.getIdentifier(_themePackageName + ":drawable/ic_tts", null, null));
        notificationCountTextColorID =
            _resources.getColor(
                _resources.getIdentifier(
                    _themePackageName + ":color/notification_count_text_color", null, null));
        headerInfoTextcolorID =
            _resources.getColor(
                _resources.getIdentifier(
                    _themePackageName + ":color/header_info_text_color", null, null));
        contactNameTextColorID =
            _resources.getColor(
                _resources.getIdentifier(
                    _themePackageName + ":color/contact_name_text_color", null, null));
        contactNumberTextColorID =
            _resources.getColor(
                _resources.getIdentifier(
                    _themePackageName + ":color/contact_number_text_color", null, null));
        bodyTextColorID =
            _resources.getColor(
                _resources.getIdentifier(_themePackageName + ":color/body_text_color", null, null));
        buttonTextColorID =
            _resources.getColor(
                _resources.getIdentifier(
                    _themePackageName + ":color/button_text_color", null, null));
        themeName =
            _resources.getString(
                _resources.getIdentifier(_themePackageName + ":string/app_name_desc", null, null));
      } catch (NameNotFoundException ex) {
        Log.e("ThemeView.setupLayoutTheme() Loading Theme Package ERROR: " + ex.toString());
        _themePackageName = Constants.DARK_TRANSLUCENT_THEME;
        _resources = _context.getResources();
        layoutBackgroundDrawable = _resources.getDrawable(R.drawable.background_panel);
        rescheduleDrawable = _resources.getDrawable(R.drawable.ic_reschedule);
        ttsDrawable = _resources.getDrawable(R.drawable.ic_tts);
        notificationCountTextColorID = _resources.getColor(R.color.notification_count_text_color);
        headerInfoTextcolorID = _resources.getColor(R.color.header_info_text_color);
        contactNameTextColorID = _resources.getColor(R.color.contact_name_text_color);
        contactNumberTextColorID = _resources.getColor(R.color.contact_number_text_color);
        bodyTextColorID = _resources.getColor(R.color.body_text_color);
        buttonTextColorID = _resources.getColor(R.color.button_text_color);
        themeName =
            _context.getString(R.string.notify_theme)
                + " - "
                + _context.getString(R.string.default_v1);
      }
    }

    _notificationWindowLinearLayout.setBackgroundDrawable(layoutBackgroundDrawable);

    _notificationCountTextView.setTextColor(notificationCountTextColorID);
    _notificationInfoTextView.setTextColor(headerInfoTextcolorID);
    _contactNameTextView.setTextColor(contactNameTextColorID);
    _contactNumberTextView.setTextColor(contactNumberTextColorID);

    _notificationDetailsTextView.setTextColor(bodyTextColorID);
    _notificationDetailsTextView.setLinkTextColor(bodyTextColorID);
    _mmsLinkTextView.setTextColor(bodyTextColorID);

    _previousButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NAV_PREV));
    _nextButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NAV_NEXT));

    _dismissButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _deleteButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _callButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _replyButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _viewButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));

    _dismissButton.setTextColor(buttonTextColorID);
    _deleteButton.setTextColor(buttonTextColorID);
    _callButton.setTextColor(buttonTextColorID);
    _replyButton.setTextColor(buttonTextColorID);
    _viewButton.setTextColor(buttonTextColorID);

    _dismissImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _deleteImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _callImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _replyImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));
    _viewImageButton.setBackgroundDrawable(getThemeButton(Constants.THEME_BUTTON_NORMAL));

    _rescheduleButton.setImageDrawable(rescheduleDrawable);
    _ttsButton.setImageDrawable(ttsDrawable);

    _themeNameTextView.setText(themeName);
  }
 public void setRightViewImage(Drawable rightViewImage) {
   rightView.setBackgroundDrawable(rightViewImage);
 }
 public void setBackgroundDrawable(Drawable drawable) {
   super.setBackgroundDrawable(drawable);
   if (this.f1351a != null) {
     this.f1351a.m2773a(drawable);
   }
 }
Beispiel #14
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) {}
        };
  }
    private void addNavButtons(ViewGroup vg) {

      addSpace(vg, 6, 6);

      LinearLayout.LayoutParams lpChild1 =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);
      LinearLayout.LayoutParams lpWrap10 =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 10);

      Context context = vg.getContext();
      LinearLayout hl = new LinearLayout(context);
      hl.setLayoutParams(lpWrap10);
      hl.setOrientation(LinearLayout.HORIZONTAL);

      // zoom out button
      bZoomOut = new ImageButton(context);
      bZoomOut.setBackgroundDrawable(null);
      bZoomOut.setLayoutParams(lpChild1);
      // bZoomOut.setText("-");
      // bZoomOut.setWidth(40);
      bZoomOut.setImageResource(getZoomOutImageResource());
      bZoomOut.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              zoomOut();
            }
          });
      hl.addView(bZoomOut);

      // zoom in button
      bZoomIn = new ImageButton(context);
      bZoomIn.setBackgroundDrawable(null);
      bZoomIn.setLayoutParams(lpChild1);
      // bZoomIn.setText("+");
      // bZoomIn.setWidth(40);
      bZoomIn.setImageResource(getZoomInImageResource());
      bZoomIn.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              zoomIn();
            }
          });
      hl.addView(bZoomIn);

      addSpace(hl, 6, 6);

      // prev button
      ImageButton bPrev = new ImageButton(context);
      bPrev.setBackgroundDrawable(null);
      bPrev.setLayoutParams(lpChild1);
      // bPrev.setText("<");
      // bPrev.setWidth(40);
      bPrev.setImageResource(getPreviousPageImageResource());
      bPrev.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              prevPage();
            }
          });
      hl.addView(bPrev);

      // page button
      mBtPage = new Button(context);
      mBtPage.setLayoutParams(lpChild1);
      String maxPage = ((mPdfFile == null) ? "0" : Integer.toString(mPdfFile.getNumPages()));
      mBtPage.setText(mPage + "/" + maxPage);
      mBtPage.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              gotoPage();
            }
          });
      hl.addView(mBtPage);

      // next button
      ImageButton bNext = new ImageButton(context);
      bNext.setBackgroundDrawable(null);
      bNext.setLayoutParams(lpChild1);
      // bNext.setText(">");
      // bNext.setWidth(40);
      bNext.setImageResource(getNextPageImageResource());
      bNext.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              nextPage();
            }
          });
      hl.addView(bNext);

      addSpace(hl, 20, 20);

      // exit button
      /*
      Button bExit=new Button(context);
            bExit.setLayoutParams(lpChild1);
            bExit.setText("Back");
            bExit.setWidth(60);
            bExit.setOnClickListener(new OnClickListener() {
      	@Override
      	public void onClick(View v) {
                 finish();
      	}
      });
            hl.addView(bExit);*/

      vg.addView(hl);

      addSpace(vg, 6, 6);
    }