-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Click Event and Listener
Weiping Huang edited this page Mar 28, 2017
·
7 revisions
Listener for clicking each button or animation-states. Check the demo for more details.
You can add a simple listener for each boom-button by adding listeners to each builder of them.
for (int i = 0; i < bmb.getPiecePlaceEnum().pieceNumber(); i++) {
SimpleCircleButton.Builder builder = new SimpleCircleButton.Builder()
.listener(new OnBMClickListener() {
@Override
public void onBoomButtonClick(int index) {
// When the boom-button corresponding this builder is clicked.
Toast.makeText(SimpleCircleButtonActivity.this, "Clicked " + index, Toast.LENGTH_SHORT).show();
}
});
bmb.addBuilder(builder);
}
If you want to manager all the click events in a method, you can use OnBoomListener
/ OnBoomListenerAdapter
:
// Use OnBoomListener to listen all methods
bmb.setOnBoomListener(new OnBoomListener() {
@Override
public void onClicked(int index, BoomButton boomButton) {
// If you have implement listeners for boom-buttons in builders,
// then you shouldn't add any listener here for duplicate callbacks.
}
@Override
public void onBackgroundClick() {
textViewForAnimation.setText("Click background!!!");
}
@Override
public void onBoomWillHide() {
textViewForAnimation.setText("Will RE-BOOM!!!");
}
@Override
public void onBoomDidHide() {
textViewForAnimation.setText("Did RE-BOOM!!!");
}
@Override
public void onBoomWillShow() {
textViewForAnimation.setText("Will BOOM!!!");
}
@Override
public void onBoomDidShow() {
textViewForAnimation.setText("Did BOOM!!!");
}
});
Or in OnBoomListenerAdapter
(Optional listener):
// Use OnBoomListenerAdapter to listen part of methods
bmb.setOnBoomListener(new OnBoomListenerAdapter() {
@Override
public void onBoomWillShow() {
super.onBoomWillShow();
// logic here
}
});
Get the states of BMB by:
bmb.isBoomed(); // Whether the BMB is boomed.
bmb.isReBoomed(); // Whether the BMB is re-boomed.
BMB will re-boom when it's boomed and back-button is clicked. If you don't want this happen:
bmb.setBackPressListened(false);
Or in xml:
app:bmb_backPressListened="false"
Notice that BMB will requestFocus
when it's going to boom. So if you need to take the focus back, you should use requestFocus
for your own view.
- Basic Usage
- Simple Circle Button
- Text Inside Circle Button
- Text Outside Circle Button
- Ham Button
- Share Style
- Custom Position
- Button Place Alignments
- Different Ways to Boom
- Ease Animations for Buttons
- Different Order for Buttons
- Other Animations Attributes for Buttons
- Click Event and Listener
- Control BMB
- Use BMB in Action Bar
- Use BMB in Tool Bar
- Use BMB in List
- Use BMB in Fragment
- Attributes for BMB or Pieces on BMB
- Cache Optimization & Boom Area
- Change Boom Buttons Dynamically
- Fade Views
- Version History
- Structure for BMB