Nightonke/BoomMenu

how set different icon and text for each bmb

Sanaebadi97 opened this issue · 3 comments

hi,
I use BMB in my project but I can set single text and single icon for all of them
how can I set for each of theme different icon and text?

this is my code

 for (int i = 0; i < binding.bmb.getPiecePlaceEnum().pieceNumber(); i++) {
      TextOutsideCircleButton.Builder builder = new TextOutsideCircleButton.Builder()
        .normalImageRes(R.drawable.ic_arrow_back_white_24dp)
        .normalText(getString(R.string.mbti_test))
        .listener(new OnBMClickListener() {
          @Override
          public void onBoomButtonClick(int index) {
            switch (index) {
              case 0:
               // Toast.makeText(SplashActivity.this, "Case 0", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(SplashActivity.this,MbtiQuestionActivity.class));
                break;

screenshot_20180907-144355

Add Something Like this into your for Loop before Building Button: ...
Drawable thedrawableforthebutton;
String textofbmb;
"Switch(i)
Case 0:
Thedrawableforthebutton = R.drawable.ic_firsticon
Textofbmb = "Your First Text"
Break;
Case 1
..."

Add this drawable/String Into Your builder pattern.

TextOutsideCircleButton.Builder builder = new TextOutsideCircleButton.Builder()
.normalImageRes(thedrawableforthebutton)
.normalText(textofbmb)

Done.

I would recommend to create a "Constant" Class where you build The buttons, instead of a for Loop (my Way i did it: "BOOM.class")
In my Sample i gave The reference of The BMB after ViewCreation to this function, Rest of The BMB custimaziation is done there.

Example Code:

// Avatar Menü
public static void HEADER_OPTIONS(BoomMenuButton BMB, final Context context,final LayoutInflater inf)
{
BMB.setPiecePlaceEnum(PiecePlaceEnum.HAM_1);
BMB.setButtonPlaceEnum(ButtonPlaceEnum.HAM_1);
BMB.setButtonEnum(ButtonEnum.Ham);

	BMB.addBuilder(new HamButton.Builder()
				   .imagePadding(new Rect(p, p , p, p)) 
				   .normalImageRes(android.R.drawable.ic_input_add)	  
				   .normalText("Aquarium hinzufügen")
				   .rotateImage(true)
				   .listener(new OnBMClickListener(){
						   @Override
						   public void onBoomButtonClick(int p1)
						   {
							   DATAHELPER.DialogConfig(context,inf,99);
						   }
					   })
				   );

}

tnx werlandm
but I choose another way like this :

` //Fab BMM
new Thread(new Runnable() {
@OverRide
public void run() {

    int[] icones = new int[]{R.drawable.file_document_box_multiple_outline, R.drawable.account_search, R.drawable.information};
    String[] texts = new String[]{getString(R.string.test), getString(R.string.person), getString(R.string.about)};

    for (int i = 0; i < binding.bmb.getPiecePlaceEnum().pieceNumber(); i++) {
      TextOutsideCircleButton.Builder builder = new TextOutsideCircleButton.Builder()
        .listener(new OnBMClickListener() {
          @Override
          public void onBoomButtonClick(int index) {
            switch (index) {
              case 0:
                startActivity(new Intent(SplashActivity.this, MbtiQuestionActivity.class));
                break;


            }
          }
        })
        .rotateText(false)
        .normalImageRes(icones[i])
        .imagePadding(new Rect(0, 0, 0, 0))
        .normalText(texts[i])
        .typeface(Typeface.createFromAsset(getAssets(), "fonts/iransans.ttf"))
        .textGravity(Gravity.CENTER)
        .textSize(15)
        .isRound(true);
      binding.bmb.addBuilder(builder);
    }

  }
}).start();

}`

tnx alot

Your Welcome. You found Your own solution. issue can be closed?