在RecyclerView中使用Boom菜单时,应用崩溃

时间:2018-09-04 16:33:38

标签: java android android-recyclerview

我的应用程序正在使用RecyclerView,并且在RecyclerView's布局中,我已经使用过Boom Menu

我已经使用动臂菜单为用户提供以下选项:

My <code>Boom Menu</code>

RecyclerViewFirebase加载数据,并且所有数据成功加载除了Boom Menu

看起来像这样:

My <code>RecyclerView</code>

只有Boom Menu的一半时间可见并且有效,当我单击空白一个时,应用崩溃,并显示以下错误:

java.lang.RuntimeException: The number of piece(3) is not equal to builders'(6)

这是我的XML代码:

<com.nightonke.boommenu.BoomMenuButton
    android:id="@+id/fragment_home_article_boom_menu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:bmb_backgroundEffect="false"
    app:bmb_boomEnum="boomParabola_3"
    app:bmb_piecePlaceEnum="piecePlace_ham_3"
    app:bmb_buttonPlaceEnum="buttonPlace_ham_3"
    app:bmb_showDuration="1000"
    app:bmb_hideDuration="1000"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

这是我的JAVA代码RecyclerView的适配器内

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

    View recyclerLayoutView = holder.view;
    BoomMenuButton fragmentHomePostBoomMenu = recyclerLayoutView.findViewById(R.id.fragment_home_article_boom_menu);
    assert fragmentHomePostBoomMenu != null;
    fragmentHomePostBoomMenu.setButtonEnum(ButtonEnum.Ham);
    for (int i = 0; i < fragmentHomePostBoomMenu.getPiecePlaceEnum().pieceNumber(); i++) {

        HamButton.Builder hamButton = new HamButton.Builder()
                .normalImageRes(boomButtonIconList[i])
                .normalText(boomButtonTextList[i])
                .subNormalText(boomButtonSubTextList[i])
                .textGravity(Gravity.CENTER_VERTICAL)
                .subTextGravity(Gravity.CENTER_VERTICAL)
                .textSize(18)
                .subTextSize(14)
                .pieceColor(Color.rgb(169, 169, 169))
                .typeface(textTypeface)
                .subTypeface(subTextTypeface)
                .normalColor(boomButtonColorList[i])
                .normalTextColor(Color.rgb(255, 255, 255))
                .subNormalTextColor(Color.rgb(255, 255, 255))
                .imagePadding(new Rect(48, 48, 48, 48))
                .listener(new OnBMClickListener() {
                    @Override
                    public void onBoomButtonClick(int index) {
                        Toast.makeText(context, boomButtonTextList[index], Toast.LENGTH_SHORT).show();
                    }
                });
        fragmentHomePostBoomMenu.addBuilder(hamButton);
    }

0 个答案:

没有答案