snackbar导致android jeally bean崩溃

时间:2016-09-08 06:46:02

标签: android

我在代码中使用了snackbar,但它给出了异常: -

Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020068 a=-1 r=0x7f020068} .

虽然它在android棒棒糖上运行良好。

创建自定义零食店的代码:

private void browsingOption()
{

    final Snackbar snackbar = Snackbar.make(imvBrowse, "", Snackbar.LENGTH_INDEFINITE);
    // Get the Snackbar's layout view
    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
    // Hide the text
    TextView textView = (TextView) layout.findViewById(android.support.design.R.id.snackbar_text);
    textView.setVisibility(View.INVISIBLE);

    // Inflate our custom view
    View snackView = getLayoutInflater().inflate(R.layout.browse_option, null);
    // Configure the view
    TextView tvGallery = (TextView) snackView.findViewById(R.id.option_tv_gallery);
    TextView tvCamera = (TextView) snackView.findViewById(R.id.option_tv_camera);
    TextView tvCancel = (TextView) snackView.findViewById(R.id.option_tv_cancel);

    tvGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(mayRequestLocation()) {
                openGallery();
            }
            snackbar.dismiss();
        }
    });

    tvCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(mayRequestLocation()) {
                openCamera();
            }
            snackbar.dismiss();
        }
    });

    tvCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            snackbar.dismiss();
        }
    });
    // Add the view to the Snackbar's layout
    layout.addView(snackView, 0);
    // Show the Snackbar
    snackbar.show();
}

0 个答案:

没有答案