How can can I add custom buttons into an AlertDialog's layout?

后端 未结 6 888
误落风尘
误落风尘 2020-12-09 08:48

I have AlertDialog with Positive and Negative buttons. In AlertDialog layout I have EditText and two Buttons (btnAdd1, btnAdd2). I want when user click at the Button btnAdd1

6条回答
  •  粉色の甜心
    2020-12-09 09:29

    what you want to do is;

    alertD.show();
    Button button = (Button)promptView.findViewById(R.id.buttonId);
    button.setOnClickListener(....)
    

    using the view to call findViewById, rather than the activity, which will look for the id in the layout that is being displayed.

提交回复
热议问题