public void addActionItem(ActionItem action) { String title = action.getTitle(); Drawable icon = action.getIcon(); View container = (View) inflater.inflate(R.layout.action_item, null); ImageView img = (ImageView) container.findViewById(R.id.iv_icon); TextView text = (TextView) container.findViewById(R.id.tv_title); if (icon != null) img.setImageDrawable(icon); else img.setVisibility(View.GONE); if (title != null) text.setText(title); else text.setVisibility(View.GONE); final int pos = mChildPos; container.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mListener != null) mListener.onItemClick(pos); dismiss(); } }); container.setFocusable(true); container.setClickable(true); mTrack.addView(container, mChildPos + 1); mChildPos++; }
/** * Add action item * * @param action {@link ActionItem} */ public void addActionItem(ActionItem action) { mActionItemList.add(action); String title = action.getTitle(); Drawable icon = action.getIcon(); View container = (View) inflater.inflate(R.layout.action_item, null); ImageView img = (ImageView) container.findViewById(R.id.iv_icon); TextView text = (TextView) container.findViewById(R.id.tv_title); if (icon != null) { img.setImageDrawable(icon); } else { img.setVisibility(View.GONE); } if (title != null) { text.setText(title); } else { text.setVisibility(View.GONE); } final int pos = mChildPos; final int actionId = action.getActionId(); container.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mItemClickListener != null) { mItemClickListener.onItemClick(QuickAction.this, pos, actionId); } if (!getActionItem(pos).isSticky()) { mDidAction = true; // workaround for transparent background bug // thx to Roman Wozniak <*****@*****.**> v.post( new Runnable() { @Override public void run() { dismiss(); } }); } } }); container.setFocusable(true); container.setClickable(true); mTrack.addView(container, mChildPos + 1); mChildPos++; }
/** * Add action item * * @param action {@link ActionItem} */ public void addActionItem(ActionItem action) { actionItems.add(action); String title = action.getTitle(); Drawable icon = action.getIcon(); View container = mInflater.inflate(R.layout.action_item_vertical, null); if (mOrientation == HORIZONTAL) { // container = mInflater.inflate(R.layout.action_item_horizontal, null); } else { } ImageView img = (ImageView) container.findViewById(R.id.iv_icon); TextView text = (TextView) container.findViewById(R.id.tv_title); if (icon != null) { img.setImageDrawable(icon); } else { img.setVisibility(View.GONE); } if (title != null) { text.setText(title); } else { text.setVisibility(View.GONE); } final int pos = mChildPos; final int actionId = action.getActionId(); container.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mItemClickListener != null) { mItemClickListener.onItemClick(QuickAction.this, pos, actionId); } if (!getActionItem(pos).isSticky()) { mDidAction = true; dismiss(); } } }); container.setFocusable(true); container.setClickable(true); if (mOrientation == HORIZONTAL && mChildPos != 0) { View separator = mInflater.inflate(R.layout.horiz_separator, null); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); separator.setLayoutParams(params); separator.setPadding(5, 0, 5, 0); mTrack.addView(separator, mInsertPos); mInsertPos++; } mTrack.addView(container, mInsertPos); mChildPos++; mInsertPos++; }
@Override public Icon getIconFor(final ActionItem aValue) { return aValue.getIcon(); }