public void showPriceFragment(View view) { if (priceFragment.getVisibility() == View.GONE) { priceFragment.setVisibility(View.VISIBLE); textPriceDefault.setCompoundDrawablesRelativeWithIntrinsicBounds( 0, 0, R.drawable.ic_chevron_right_black_24dp, 0); } else { priceFragment.setVisibility(View.GONE); textPriceDefault.setCompoundDrawablesRelativeWithIntrinsicBounds( 0, 0, R.drawable.ic_expand_more_black_24dp, 0); } }
public void showScheduleFragment(View view) { if (scheduleFragment.getVisibility() == View.GONE) { scheduleFragment.setVisibility(View.VISIBLE); textOpeningStatus.setCompoundDrawablesRelativeWithIntrinsicBounds( 0, 0, R.drawable.ic_chevron_right_black_24dp, 0); } else { specialDaysFragment.setVisibility(View.GONE); scheduleFragment.setVisibility(View.GONE); textOpeningStatus.setCompoundDrawablesRelativeWithIntrinsicBounds( 0, 0, R.drawable.ic_expand_more_black_24dp, 0); } }
@Override public View getView(int position, View _view, ViewGroup parent) { View view = _view; Object menuItem = getItem(position); if (menuItem instanceof MenuCategory) { if (view == null) { view = LayoutInflater.from(mContext) .inflate(R.layout.view_navigation_drawer_item, parent, false); } ((TextView) view).setText(((MenuCategory) menuItem).mTitle); } else { if (view == null) { view = LayoutInflater.from(mContext) .inflate(R.layout.view_navigation_drawer_item, parent, false); } TextView itemTitle = (TextView) view; itemTitle.setText(((MenuActivity) menuItem).mTitle); // Setting icon menu item int iconResource = ((MenuActivity) menuItem).mIconResource; if (iconResource > 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { itemTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(iconResource, 0, 0, 0); } else { itemTitle.setCompoundDrawablesWithIntrinsicBounds(iconResource, 0, 0, 0); } } } return view; }
public static void setCompoundDrawablesRelativeWithIntrinsicBounds( @NonNull TextView paramTextView, @Nullable Drawable paramDrawable1, @Nullable Drawable paramDrawable2, @Nullable Drawable paramDrawable3, @Nullable Drawable paramDrawable4) { paramTextView.setCompoundDrawablesRelativeWithIntrinsicBounds( paramDrawable1, paramDrawable2, paramDrawable3, paramDrawable4); }
/** * @see android.widget.TextView#setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int, * int) */ public static void setCompoundDrawablesRelativeWithIntrinsicBounds( TextView textView, int start, int top, int end, int bottom) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1) { // Work around the platform bug described in setCompoundDrawablesRelative() above. boolean isRtl = isLayoutRtl(textView); textView.setCompoundDrawablesWithIntrinsicBounds( isRtl ? end : start, top, isRtl ? start : end, bottom); } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) { textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom); } else { textView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); } }
public static void setCompoundDrawablesRelativeWithIntrinsicBounds( @NonNull TextView paramTextView, int paramInt1, int paramInt2, int paramInt3, int paramInt4) { paramTextView.setCompoundDrawablesRelativeWithIntrinsicBounds( paramInt1, paramInt2, paramInt3, paramInt4); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Override public View getView(final int position, final View convertView, final ViewGroup parent) { final View view = super.getView(position, convertView, parent); if (mEntryIcons != null) { final TextView text = (TextView) view.findViewById(android.R.id.text1); text.setCompoundDrawablePadding(24); // final int dir = getViewLayoutDirection(text); // int actualIconSide = iconSide; switch (iconSide) { case ICON_SIDE_START: text.setCompoundDrawablesRelativeWithIntrinsicBounds(mEntryIcons[position], 0, 0, 0); break; case ICON_SIDE_END: text.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, mEntryIcons[position], 0); break; case ICON_SIDE_RIGHT: text.setCompoundDrawablesWithIntrinsicBounds(0, 0, mEntryIcons[position], 0); break; case ICON_SIDE_LEFT: default: text.setCompoundDrawablesWithIntrinsicBounds(mEntryIcons[position], 0, 0, 0); break; } // switch (iconSide) { // case ICON_SIDE_END: // actualIconSide = dir == 1 ? ICON_SIDE_RIGHT : ICON_SIDE_LEFT; // break; // case ICON_SIDE_START: // case ICON_SIDE_AUTO: // actualIconSide = dir == 1 ? ICON_SIDE_LEFT : ICON_SIDE_RIGHT; // break; // default: // } // switch (actualIconSide) { // case ICON_SIDE_RIGHT: // text.setCompoundDrawablesWithIntrinsicBounds(0, 0, // mEntryIcons[position], 0); // break; // case ICON_SIDE_LEFT: // default: // // text.setCompoundDrawablesWithIntrinsicBounds(mEntryIcons[position], 0, 0, 0); // break; // } // Log.v("DEMO", "defaultLocale: " + Locale.getDefault() // + ", API: " + Build.VERSION.SDK_INT // + ", dir: " + dir // + ", iconSide: " + iconSide // + ", actualIconSide: " + actualIconSide); } view.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { v.requestFocus(); IconListPreference.this.callChangeListener(getEntryValues()[position]); setValueIndex(position); Dialog mDialog = getDialog(); mDialog.dismiss(); } }); return view; }