Example #1
0
  private void initMainImage() {
    final ImageView mainImage = findView(R.id.main_image);
    final DrawableSelector mainSelector =
        DrawableSelector.simple(this, R.color.color_1, R.color.color_7)
            .setEnterFadeDuration(300)
            .setExitFadeDuration(300)
            .build();
    final Drawable mainDrawable = mainSelector.build(R.drawable.ic_android_white_48dp);
    mainImage.setImageDrawable(mainDrawable);

    findView(R.id.main_redraw)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                updateAdapterColors();
              }
            });
  }
Example #2
0
 void update(int normalColor, int pressedColor, int selectedColor) {
   mDrawableSelector =
       DrawableSelector.builder(mContext)
           .addState(SelectorState.PRESSED, pressedColor)
           .addState(SelectorState.ACTIVATED, selectedColor)
           .addState(SelectorState.WILD_CARD, normalColor)
           .setEnterFadeDuration(200)
           .setExitFadeDuration(200)
           .build();
 }
Example #3
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      final View view;
      if (convertView == null) {
        view = mInflater.inflate(R.layout.adapter_item, parent, false);
        view.setTag(new Holder(view));
      } else {
        view = convertView;
      }

      final Holder holder = (Holder) view.getTag();
      final Drawable dr = mDrawableSelector.build(R.drawable.ic_android_white_48dp);
      holder.icon.setImageDrawable(dr);
      holder.text.setText(String.format("Item #%1$d", position));

      return view;
    }