LearningBasics
LearningBasics

Reputation: 664

Android: Error handling onClickListener

I have some activity handling the click event on any view

public class MainActivity extends Activity implements OnClickListener{
    ...
}

I have tried to override via this

public void onClick(View v)
{
    switch (v.getId())
    {
        case R.id.button1:
            mp.start();  
            break;
        case R.id.button2:
            mp.pause();  
            break;
        case R.id.button3:
            mp.stop();  
            break;
        default:
            break;
    }
}

But it is asking me to change to handle click event via

@Override
    public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub

        }

Has the api's changed , what is the issue I dont have any idea about ?

Upvotes: 1

Views: 60

Answers (1)

Raghunandan
Raghunandan

Reputation: 133560

You need to import

import android.view.View.OnClickListener;

and not

import android.content.DialogInterface.OnClickListener;

See this

http://developer.android.com/reference/android/view/View.OnClickListener.html

Upvotes: 7

Related Questions