title: Open a custom dialog after click a button Android
body: <p>I would like to open a custom dialog after the click of a button. The code of button in XML is: </p>
  
  <pre><code>&lt;Button
              android:id="@+id/Button1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="@dimen/BorderMargin"
              android:layout_marginRight="@dimen/BorderMargin"
              android:background="#D2D2D2"
              android:onClick="openDialog1"
              android:padding="17dip"
              android:text="@string/ButtonAdd" /&gt;
  </code></pre>
  
  <p>After click, the button open the method "openDialog1":</p>
  
  <pre><code>public void openDialog1(View view) {
  
      final Dialog dialog = new Dialog(this.getApplicationContext());
      dialog.setContentView(R.layout.dialogbrand_layout);
      dialog.setTitle("Hello");
  
      TextView textViewUser = new TextView(getApplicationContext());
      textViewUser = (TextView) findViewById(R.id.textBrand);
      textViewUser.setText("Hi");
  
      dialog.show();
  }
  </code></pre>
  
  <p>I tried to execute this cose but the application crash on the textViewUser.setText </p>
  
  <p>Any ideas?</p>