0

メインアクティビティがバックグラウンドで開いている間に、いくつかの機能の使用方法を知るための指示として、ボトムシートを使用してアプリケーション(メインアクティビティ)を開始したいこのプロジェクトを行っています。

ボトムシートを別のシートに移行する方法は知っていますが、最初のボトムシートをアクティブにするためにボタンが必要であるという主な問題があるため、ボタンを必要とせずにアプリケーションの起動時に自動的に実行できるかどうかという質問がありますボトムシート内のボタンをクリックした後に閉じられますか?

これは私のJavaコードです:

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();

        }

    });
4

1 に答える 1