Calling one method multiple times - android code
<p>My layout has 4 button. One is the 'Right' answer and the other 3 are 'Wrong' answers.
I want the SAME popup to be displayed with one of the 3 'wrong' buttons are pressed. Here is the code that i have got.</p>

<p>I dont want to repeat this Code for EACH of the 3 buttons, how do i call the same code with the different button names? </p>

<pre><code>    ImageButton rredButton=(ImageButton)findViewById(R.id.RredButton);
    rredButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            LayoutInflater layoutInflater
            = (LayoutInflater)getBaseContext()      
            .getSystemService(LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.popupright, null);
            final PopupWindow popupWindow = new PopupWindow(               
                    popupView,                
                    LayoutParams.WRAP_CONTENT,                       
                    LayoutParams.WRAP_CONTENT);                            

            Button btnDismiss = (Button)popupView.findViewById(R.id.nextscreen);             
            btnDismiss.setOnClickListener(new Button.OnClickListener(){     
                @Override     
                public void onClick(View v) {      
                    Intent myintent1 = new Intent(colorActivity.this,LearningTimeMenu.class);
                    startActivity(myintent1);
                }
            });
        }});
</code></pre>
