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();
答案 0 :(得分:0)
也许你需要传递parentView
中的BottomSheetBehaviour.from()
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();
}
});
}
}