I'm doing this project where I want to start an application ( Main activity ) with a bottom sheet as instruction to know how to use some functions, while the main activity is open at the background.
I've known how to transition between a bottom sheet to another but my main problem that the first bottom sheet needs a button it self to be activated, so my question is can it be done automatically when the application starts without the need of a button then dismissed after clicking on the button inside the bottom sheet ?
This is my Java Code:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button buttonShow = findViewById(R.id.button_start);
buttonShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(
MainActivity.this, R.style.BottomSheetDesign
);
View bottomSheetView = LayoutInflater.from(getApplicationContext())
.inflate(
R.layout.layout_bottom_sheet,
(LinearLayout)findViewById(R.id.BottomSheetContainer)
);
bottomSheetView.findViewById(R.id.ButtonNext).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final BottomSheetDialog bottomSheetDialog1 = new BottomSheetDialog(
MainActivity.this, R.style.BottomSheetDesign
);
View bottomSheetView1 = LayoutInflater.from(getApplicationContext())
.inflate(
R.layout.layout_bottom_sheet1,
(LinearLayout)findViewById(R.id.BottomSheetContainer1)
);
bottomSheetView1.findViewById(R.id.ButtonDone).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bottomSheetDialog1.dismiss();
}
});
bottomSheetDialog.dismiss();
bottomSheetDialog1.setContentView(bottomSheetView1);
bottomSheetDialog1.show();
}
});
bottomSheetDialog.setContentView(bottomSheetView);
bottomSheetDialog.show();
}
});