title: Android BottomSheetDialog layout have button, onclick navigat to activity
body: <p>I have BottomSheetDialog layout xml file which been called by my activity. And BottomSheetDialog has 2 buttons. On clicking on button inside BottomSheetDialog it should take me to another Activity.</p>
  
  <p><a href="https://i.stack.imgur.com/rHLn3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rHLn3.png" alt="Related BottomSheetDialog Layout Image"></a></p>
  
  <p>main_layout.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#fff"
      android:orientation="vertical"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:context="com.ezeelearn.colorstonz.ezeelearn.PhysicsTestSelectorActivity"
      tools:showIn="@layout/app_bar_physics_lesson"&gt;
  
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;TableLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="horizontal"
              android:id="@+id/lesson_list"&gt;
  
  
  
          &lt;/TableLayout&gt;
  
  
      &lt;/ScrollView&gt;
  
      &lt;include layout="@layout/bottom_sheet_layout" /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>bottom_sheet_layout.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      android:id="@+id/RelativeLayoutSheet"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      app:layout_behavior="@string/bottom_sheet_behavior"
      android:background="#ffffff"
      app:behavior_hideable="true"
      android:padding="20dp"
      &gt;
  
      &lt;TableLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
          &lt;TableRow
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:weightSum="2"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_weight="1"
                  android:paddingRight="50dp"
                  android:paddingLeft="50dp"
                  android:paddingTop="20dp"
                  android:paddingBottom="20dp"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"&gt;
  
                  &lt;Button
                      android:layout_width="100dp"
                      android:layout_height="100dp"
                      android:layout_weight="1"
                      android:background="#fff"
                      android:drawableTop="@drawable/google_cardboard"
                      android:drawablePadding="6dp"
                      android:gravity="left|center"
                      android:height="60dp"
                      android:padding="6dp"
                      android:text="Video"
                      android:id="@+id/bottom_sheet_video_btn"
                      android:textAlignment="center"
                      android:fontFamily="sans-serif-light"
                      android:foreground="?android:attr/selectableItemBackground"
                      android:textColor="#666" /&gt;
  
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_weight="1"
                  android:paddingRight="50dp"
                  android:paddingLeft="50dp"
                  android:paddingTop="20dp"
                  android:paddingBottom="20dp"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"&gt;
  
                  &lt;Button
                      android:layout_width="100dp"
                      android:layout_height="100dp"
                      android:layout_weight="1"
                      android:background="#fff"
                      android:drawableTop="@drawable/bulletin_board"
                      android:drawablePadding="6dp"
                      android:gravity="left|center"
                      android:height="60dp"
                      android:padding="6dp"
                      android:text="Lesson"
                      android:id="@+id/bottom_sheet_lesson_btn"
                      android:textAlignment="center"
                      android:fontFamily="sans-serif-light"
                      android:foreground="?android:attr/selectableItemBackground"
                      android:textColor="#666" /&gt;
  
              &lt;/LinearLayout&gt;
  
          &lt;/TableRow&gt;
  
      &lt;/TableLayout&gt;
  
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends Activity{
  
      BottomSheetDialog bottomSheetDialog;
      BottomSheetBehavior bottomSheetBehavior ;
  
      @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main_layout);
  
          List&lt;String&gt; lessonNames = new ArrayList&lt;String&gt;();
          lessonNames.add("Photosynthesis in Higher Plants");
          lessonNames.add("The Living World");
          lessonNames.add("Biological Classification");
          lessonNames.add("Plant Kingdom");
          lessonNames.add("Animal Kingdom");
          lessonNames.add("Morphology of Flowering Plants");
          lessonNames.add("Anatomy of Flowering Plants");
          lessonNames.add("Structural Organisation in Animals");
          lessonNames.add("Cell-The Unit of Life");
          lessonNames.add("Biomolecules");
          lessonNames.add("Transport in Plants");
          lessonNames.add("Mineral Nutrition");
          lessonNames.add("Flowering Plants");
  
          TableLayout lessonList = (TableLayout) findViewById(R.id.lesson_list);
          List&lt;TableLayout&gt; lessonTableList = new ArrayList&lt;TableLayout&gt;();
  
          for(int i = 0; i &lt; lessonNames.size(); i++) {
  
              TableRow tableRow = new TableRow(this);
              TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
              tableRow.setLayoutParams(tableLayoutParams);
              tableRow.setPadding(30, 25, 30, 25);
              tableRow.setBackgroundDrawable(getResources().getDrawable(R.drawable.textlines));
  
  
              TextView textView = new TextView(this);
              textView.setText(String.format("%02d", (i+1))+".  "+lessonNames.get(i));
              /*textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_dots_vertical, 0);*/
              textView.setTextSize(17);
  
              tableRow.addView(textView);
  
  
              /*TextView textView = new TextView(this);
              textView.setText(String.format("%02d", (i+1))+".  "+lessonNames.get(i));
              textView.setPadding(20, 25, 20, 25);
              textView.setTextSize(17);
              textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_dots_vertical, 0);
              textView.setLayoutParams(new TableLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  
              textView.setBackgroundDrawable(getResources().getDrawable(R.drawable.textlines));
  
              lessonList.addView(textView);*/
              lessonList.addView(tableRow);
              lessonTableList.add(lessonList);
          }
  
          for(final TableLayout tableLayout: lessonTableList) {
              tableLayout.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      bottomSheetDialog = new BottomSheetDialog(PhysicsLessonActivity.this);
  
                      View view = getLayoutInflater().inflate(R.layout.bottom_sheet_layout, null);
                      bottomSheetDialog.setContentView(view);
                      bottomSheetDialog.show();
  
  
                      bottomSheetDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
                          @Override
                          public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                              Log.d("BottomSheetVideoBtn", "called");
                              return false;
                          }
                      });
  
  
                  }
              });
          }
  
          Button bottomSheetVideoBtn = (Button) findViewById(R.id.bottom_sheet_video_btn);
          Button bottomSheetLessonBtn = (Button) findViewById(R.id.bottom_sheet_lesson_btn);
  
          bottomSheetVideoBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(getApplicationContext(), PhysicsActivity.class);
                  Log.d("BottomSheetVideoBtn", "called");
                  startActivity(intent);
              }
          });
  
          bottomSheetLessonBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Toast.makeText(getBaseContext(), "Lesson Button Clicked", Toast.LENGTH_LONG).show();
              }
          });
  
          ImageButton backToPHome = (ImageButton) findViewById(R.id.back_to_home);
          backToPHome.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(getApplicationContext(), PhysicsActivity.class);
                  startActivity(intent);
              }
          });
  
      }
  
  }
  </code></pre>