Saturday, February 25, 2012

Re: [android-developers] Issue with OnClick

If you use a Dialog (e.g. AlertDialog) then you need to use DialogInterface.OnClickListener ( http://developer.android.com/reference/android/content/DialogInterface.OnClickListener.html ). If you use a View then it's View.OnClickListener ( http://developer.android.com/reference/android/view/View.OnClickListener.html ).

Check also your imports and look if you see some odd/wrong ones. (sometimes it happens that you import the wrong class...it happened a lot to me with the various LayoutParams classes).


On Sat, Feb 25, 2012 at 10:20 AM, Michal Šanda <ja@michalsanda.cz> wrote:
Hello, I am trying to do this

 public void onClick(View v) {
               // TODO Auto-generated method stub
               if(v==findViewById(R.id.Button1)){

               Intent intent = new Intent(this,OknoActivity.class);

               startActivityForResult(intent,ACTIVITY_INTENT_OKNOACTIVITY);
               }

but eclipse says this error

Description     Resource        Path    Location        Type
The type Android_testActivity must implement the inherited abstract
method DialogInterface.OnClickListener.onClick(DialogInterface, int)
Android_testActivity.java       /Android_test/src/cz/msanda/test        line 13
Java Problem

Eclipse offers fix, but its this
public void onClick(DialogInterface arg0, int arg1) {
..
..
..
-------

What's wrong? I read a lot of examples but I don't see any problem....

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
YuviDroid
Check out Launch-X (a widget to quickly access your favorite apps and contacts!)
http://android.yuvalsharon.net

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment