Getting rid of "==" syntax error in android
<p>The <code>elseif(v == button2)</code> line gives an error saying that "Syntax error on token '==', delete this token". I got the idea of using this from the topic "Variable OnClick listener android" from this website. Can anyone please tell me how to use it?</p>

<p>Here is my code:</p>

<pre><code>    View.OnClickListener yourListener = new View.OnClickListener(){
        public void onClick(View v){
            if( v ==  button1){
                new AlertDialog.Builder(this)
                .setTitle("Paracettamol")
                .setMessage("This medicine is generally used to cure Fever")
                .setNeutralButton("OK", null)
                .show();}
            }
        elseif( v == button2){
            new AlertDialog.Builder(this)

        .setTitle("sertraline")
        .setMessage("This medicine is generally used to cure Head aches")
        .setNeutralButton("OK", null)
        .show();

        }



        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

        }
        }  ; 
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

        }
        }
</code></pre>

<p>The answer of the asked question mentioned above has the following code:</p>

<pre><code>Button btn1, btn2;
public void onCreate(Bundle b)
{
    // here you do normal things like assigning a
    // content view to the activity, initiate buttons, etc.

    // then you assign the same listener to both buttons
    btn1.setOnClickListener(yourListener);
    btn2.setOnClickListener(yourListener);
}

// declare a OnClickListener that will execute different actions
// depending on the view that was clicked
View.OnClickListener yourListener = new View.OnClickListener(){
    public void  onClick  (View  v){
        if( v == btn1 ){
            // do something 
        }
        elseif( v == btn1 ){
            // do another thing
        }
    }
};
</code></pre>
