Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did not succeed yet to run the Ham Menu #255

Open
Povonn opened this issue Aug 17, 2022 · 1 comment
Open

Did not succeed yet to run the Ham Menu #255

Povonn opened this issue Aug 17, 2022 · 1 comment

Comments

@Povonn
Copy link

Povonn commented Aug 17, 2022

I'm a learner and I seek your help. I want to add this button into a project.

I wrote the following code in my activity_main.xml

<com.nightonke.boommenu.BoomMenuButton
        android:id="@+id/bmb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:bmb_buttonEnum="ham"
        app:bmb_buttonPlaceEnum="buttonPlace_ham_4"
        app:bmb_piecePlaceEnum="piecePlace_ham_4"
        />

I created a java file Nn.java

package myappname.name;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;



import com.nightonke.boommenu.BoomButtons.ButtonPlaceEnum;
import com.nightonke.boommenu.BoomButtons.HamButton;
import com.nightonke.boommenu.BoomMenuButton;
import com.nightonke.boommenu.ButtonEnum;
import com.nightonke.boommenu.Piece.PiecePlaceEnum;



public class Nn extends AppCompatActivity {


    private BoomMenuButton bmb;

    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bmb = (BoomMenuButton) findViewById(R.id.bmb);
        bmb.setButtonEnum(ButtonEnum.Ham);
        bmb.setPiecePlaceEnum(PiecePlaceEnum.HAM_4);
        bmb.setButtonPlaceEnum(ButtonPlaceEnum.HAM_4);
        bmb.addBuilder(getHamButtonBuilder());
        bmb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                for (int i = 0; i < bmb.getPiecePlaceEnum().pieceNumber(); i++) {
                    HamButton.Builder builder = new HamButton.Builder()
                            .normalImageRes(R.drawable.butterfly)
                            .normalTextRes("Butter Doesn't fly!")
                            .subNormalTextRes("Little butter Doesn't fly, either!");
                    bmb.addBuilder(builder);
                }
            }
        });



    }

    ;


    static HamButton.Builder getHamButtonBuilder() {
        return new HamButton.Builder()
                .normalImageRes(getImageResource())
                .normalTextRes(R.string.text_ham_button_text_normal)
                .subNormalTextRes(R.string.text_ham_button_sub_text_normal);
    }

    private static int[] imageResources = new int[]{
            R.drawable.bat,
            R.drawable.bear,
            R.drawable.bee,
            R.drawable.butterfly,
    };

    private static int imageResourceIndex = 0;

    static int getImageResource() {
        if (imageResourceIndex >= imageResources.length) imageResourceIndex = 0;
        return imageResources[imageResourceIndex++];
    }

}

Whenever I click the Menu button, I close the app.
Would someone help me please. I one four buttons, to of them redirect to external links

@nasamio
Copy link

nasamio commented Sep 12, 2023

plz run your app and filter ‘fatal' tag in your logcat,then you can see why your app crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants