我遵循了教程,但是代码无法正常运行。在本教程中,他只键入BottomSheetDialog();
并且在圆括号内没有要求,但就我的活动而言,它需要在其中放置一些内容,而我不知道。
private GoogleMap mMap;
ArrayList<LatLng> MarkerPoints;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
Marker mCurrLocationMarker;
LocationRequest mLocationRequest;
double mLatitude;
double mLongitude;
private FirebaseAuth mAuth;
private Button btnShow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Initialize Firebase Auth
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkLocationPermission();
}
// Initializing
MarkerPoints = new ArrayList<>();
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
btnShow = (Button) findViewById(R.id.bottomsheet);
btnShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog();
bottomSheetDialog.show(getSupportFragmentManager(),bottomSheetDialog.getTag());
}
});
}
答案 0 :(得分:0)
根据BottomSheetDialog
代码,仅支持以下一种构造函数:
public BottomSheetDialog(@NonNull Context context) {
...
}
public BottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
...
}
因此您缺少context
参数:
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(context);