簡體   English   中英

Android的底層表對話框

[英]Android Bottom Sheet Dialog

package com.darkweb.android.amityaaroh.LoginActivity;

import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;

import com.darkweb.android.amityaaroh.R;

public class Events extends AppCompatActivity{

Button button;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.events);

    button = (Button)findViewById(R.id.event);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            BottomSheetDialog bottomSheerDialog = new BottomSheetDialog(Events.this);
            View parentView = getLayoutInflater().inflate(R.layout.dialog,null);
            bottomSheerDialog.setContentView(parentView);
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(View)parentView.getParent();
            bottomSheetBehavior.setPeekHeight(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,200,getResources().getDisplayMetrics());
            bottomSheerDialog.show();
        }
    });


}

}

錯誤代碼:錯誤:(30,89)錯誤:“;” 預期的錯誤:(31,54)錯誤:'.class'預期的錯誤:(31,55)錯誤:';' 預期的錯誤:任務':app:compileDebugJavaWithJavac'的執行失敗。

編譯失敗; 有關詳細信息,請參見編譯器錯誤輸出。

第30行:BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(View)parentView.getParent();

也許您需要像這樣在BottomSheetBehaviour.from()傳遞parentView

public class Events extends AppCompatActivity{

    Button button;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.events);

        button = (Button)findViewById(R.id.event);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                BottomSheetDialog bottomSheerDialog = new BottomSheetDialog(Events.this);
                View parentView = getLayoutInflater().inflate(R.layout.dialog,null);
                bottomSheerDialog.setContentView(parentView);
                BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(parentView.getParent());
                bottomSheetBehavior.setPeekHeight(int); TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,200,getResources().getDisplayMetrics());
                bottomSheerDialog.show();
            }
        });


    }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM