How to set button click listener for Custom Dialog?

后端 未结 7 424
遇见更好的自我
遇见更好的自我 2021-01-11 11:30

I have made a main Dialog class on which I send the layout ID and shows the layout as a Dialog now when I send the layout from calling class it pop

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 12:19

    In 2019 this work for me. You can change text view with button.

      Dialog mdialog = new Dialog(this);
          mdialog.setContentView(R.layout.activity_select_type);
            mdialog.show();
    TextView view = mdialog.findViewById(R.id.viewQuotes);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(MainActivity.this, "Working...", Toast.LENGTH_SHORT).show();
        }
    });
    

提交回复
热议问题