How to set button click listener for Custom Dialog?

后端 未结 7 492
遇见更好的自我
遇见更好的自我 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:13

    There you go:

        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(id);
    
        Button signInbutton=(Button)findViewById(R.id.signInButton);
        signInButton.setOnClickListener(this);
        Button closebutton=(Button)findViewById(R.id.closeButton);
        closeButton.setOnClickListener(this);
        }
    
    @Override
    public void onClick(View v) {
        if(R.id.closeButton == v.getId()) { 
            closeButton(v);
        } else {
    
        // do the same for signInButton
        }
    
    }
    

    Suggest you learn the basic beforehand.

提交回复
热议问题