I would like to open a custom dialog after the click of a button. The code of button in XML is:
<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" />
After click, the button open the method "openDialog1":
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();
}
I tried to execute this cose but the application crash on the textViewUser.setText
Any ideas?