Methods Summary |
---|
public void | addButton(int labelResId, int iconResId, java.lang.Object value)
final Button b = (Button) mInflater.inflate(R.layout.segmented_button, this, false);
b.setTag(LABEL_RES_KEY, labelResId);
b.setText(labelResId);
b.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0);
final LayoutParams lp = (LayoutParams) b.getLayoutParams();
if (getChildCount() == 0) {
lp.leftMargin = lp.rightMargin = 0; // first button has no margin
}
b.setLayoutParams(lp);
addView(b);
b.setTag(value);
b.setOnClickListener(mClick);
Interaction.register(b, new Interaction.Callback() {
@Override
public void onInteraction() {
fireInteraction();
}
});
|
private void | fireInteraction()
if (mCallback != null) {
mCallback.onInteraction();
}
|
private void | fireOnSelected()
if (mCallback != null) {
mCallback.onSelected(mSelectedValue);
}
|
public java.lang.Object | getSelectedValue()
return mSelectedValue;
|
public void | setCallback(com.android.systemui.volume.SegmentedButtons$Callback callback)
mCallback = callback;
|
public void | setSelectedValue(java.lang.Object value)
if (Objects.equals(value, mSelectedValue)) return;
mSelectedValue = value;
for (int i = 0; i < getChildCount(); i++) {
final TextView c = (TextView) getChildAt(i);
final Object tag = c.getTag();
final boolean selected = Objects.equals(mSelectedValue, tag);
c.setSelected(selected);
c.getCompoundDrawables()[1].setTint(mContext.getResources().getColor(selected
? R.color.segmented_button_selected : R.color.segmented_button_unselected));
}
fireOnSelected();
|
public void | updateLocale()
for (int i = 0; i < getChildCount(); i++) {
final Button b = (Button) getChildAt(i);
final int labelResId = (Integer) b.getTag(LABEL_RES_KEY);
b.setText(labelResId);
}
|