Я бы хотел открыть пользовательское диалоговое окно после нажатия кнопки. Код кнопки в XML является:Откройте пользовательское диалоговое окно после нажатия кнопки Android
<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" />
После нажатия, кнопка открытие метода «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();
}
Я пытался выполнить эту Co, но крах приложения на textViewUser.setText
Любые идеи?
http://stackoverflow.com/questions/16534888/how-can-i-create-my-own-theme-for-alertdialog/16534981#16534981 – Sam
разместить свой собственный диалог макет – Raghunandan
использовать диалог контекста деятельности Dialog = новый Диалог (ActivityName.this); – Raghunandan