List of usage examples for android.widget ImageView setImageState
public void setImageState(int[] state, boolean merge)
From source file:net.simno.klingar.ui.PlayerController.java
@Override public void onPrepareOptionsMenu(@NonNull Menu menu) { MenuItem item = menu.findItem(R.id.action_queue_track); ImageView actionView = (ImageView) MenuItemCompat.getActionView(item); actionView.setImageState(isQueueVisible ? TRACK : QUEUE, true); actionView.setContentDescription(isQueueVisible ? descTrack : descQueue); actionView.setOnClickListener(view -> { actionView.setImageState(isQueueVisible ? QUEUE : TRACK, true); actionView.setContentDescription(isQueueVisible ? descQueue : descTrack); toggleQueue();// www . j av a 2 s .c om }); }
From source file:com.google.samples.apps.iosched.util.LPreviewUtilsImpl.java
@Override public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck, boolean allowAnimate) { AnimatedStateListDrawable drawable = (AnimatedStateListDrawable) mActivity.getResources() .getDrawable(R.drawable.add_schedule_fab_icon_anim); imageView.setImageDrawable(drawable); if (allowAnimate) { // TODO: figure out if there's a way to always animate from current state imageView.setImageState(isCheck ? STATE_UNCHECKED : STATE_CHECKED, false); drawable.jumpToCurrentState();// w w w.java 2 s. c om imageView.setImageState(isCheck ? STATE_CHECKED : STATE_UNCHECKED, false); } else { imageView.setImageState(isCheck ? STATE_CHECKED : STATE_UNCHECKED, false); drawable.jumpToCurrentState(); } }
From source file:com.evvsoft.treeview.SimpleJsonTreeViewAdapter.java
private View createViewFromResource(TreeViewNode node, int position, View convertView, ViewGroup parent, int resource, Boolean isGroup) { View v;/*www .ja va 2 s .co m*/ if (convertView == null || convertView.getId() != (int) node.getId()) { v = mInflater.inflate(R.layout.treeview_item_wrapper, parent, false); v.setId((int) node.getId()); View list_item = mInflater.inflate(resource, parent, false); ((ViewGroup) v).addView(list_item); View indented = v.findViewById(R.id.treeview_item_image); int resId = isGroup ? mGroupIndicatorRes : mChildIndicatorRes; if (resId != 0) ((ImageView) indented).setImageResource(resId); else { ((ViewGroup) v).removeView(indented); indented = list_item; } ViewGroup.LayoutParams params = indented.getLayoutParams(); ((LinearLayout.LayoutParams) params).leftMargin = mIndent * node.getLevel(); indented.requestLayout(); } else v = convertView; ImageView image = (ImageView) v.findViewById(R.id.treeview_item_image); if (image != null) image.setImageState(STATE[node.isExpanded() ? STATE_EXPANDED : !node.isGroupNode() && node.isLast() ? STATE_LAST : STATE_NONE], true); bindView(node, v); return v; }