无法解析构造函数 'BottomSheetDialog()'
Cannot resolve constructor 'BottomSheetDialog()'
我按照教程进行操作,但代码运行不佳。在教程中,他只输入 BottomSheetDialog();
并且在括号内没有要求,但在我的 activity 中,它需要在那里放一些东西,我不知道。
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());
}
});
}
根据BottomSheetDialog
代码,仅支持以下构造函数之一:
public BottomSheetDialog(@NonNull Context context) {
...
}
public BottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
...
}
所以您缺少一个 context
参数:
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(context);
我按照教程进行操作,但代码运行不佳。在教程中,他只输入 BottomSheetDialog();
并且在括号内没有要求,但在我的 activity 中,它需要在那里放一些东西,我不知道。
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());
}
});
}
根据BottomSheetDialog
代码,仅支持以下构造函数之一:
public BottomSheetDialog(@NonNull Context context) {
...
}
public BottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
...
}
所以您缺少一个 context
参数:
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(context);