Issue with OnClick

Put your problem here if it does not fit any of the other categories.

Issue with OnClick

Postby mrm[cz] » Sat Feb 25, 2012 10:37 am

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....
mrm[cz]
Freshman
Freshman
 
Posts: 4
Joined: Sat Feb 25, 2012 10:36 am

Top

Re: Issue with OnClick

Postby Phyll » Sat Feb 25, 2012 12:23 pm

Hi mrm[cz],

Have you tried letting Eclipse make the fix, then moving your code down there and erasing your version of the same thing? Sometimes Eclipse gets confused and likes its version better.

That's happened to me but I don't know why.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Issue with OnClick

Postby mrm[cz] » Sat Feb 25, 2012 3:22 pm

Hi Phyll, I tried move my code into generated Eclipse method.. but it has diferent arguments, I dont know how it use( i need arg View v ..)... or do you mean something else?
mrm[cz]
Freshman
Freshman
 
Posts: 4
Joined: Sat Feb 25, 2012 10:36 am

Re: Issue with OnClick

Postby Phyll » Sat Feb 25, 2012 5:18 pm

Hi mrm[cz],

The only thing I can guess from what you have shown us is that your activity is extended from a dialog maybe and that you haven't also implemented all of the methods it needs to have overridden. I don't know if that method it wants to make for you is something you need or not. It just wants it. It may also be that the class you are extending doesn't have an onclick method.

I have to see some more of your code so that I can try to duplicate your problem. Otherwise I'm just kind of guessing.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Issue with OnClick

Postby mrm[cz] » Sat Feb 25, 2012 10:50 pm

Hmmm ok.. I think the easiest way is this... here is project :arrow:

Android_test.rar
http://goo.gl/l2huj
pass: Android_test

Thank you so much
mrm[cz]
Freshman
Freshman
 
Posts: 4
Joined: Sat Feb 25, 2012 10:36 am

Re: Issue with OnClick

Postby Phyll » Sun Feb 26, 2012 12:19 am

Hi

Just a couple of things that need fixed.

First, you have the wrong imports (2) at the top.

Get rid of these two:

import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;

Replace them with these two:

import android.view.View;
import android.view.View.OnClickListener;

And add this to your button setup:

Button1.setOnClickListener(this);

In the future, if you want to send me something just go ahead and PM it as a zipped file that works pretty good.

Hope this helps.

Phyll

By the way, it crashes when you press the button because that's only partially done.
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Re: Issue with OnClick

Postby mrm[cz] » Sun Feb 26, 2012 10:30 pm

Hi, ok and thank you so much for help... now it works..:-) stupid mistake.. :-( ...
mrm[cz]
Freshman
Freshman
 
Posts: 4
Joined: Sat Feb 25, 2012 10:36 am

Re: Issue with OnClick

Postby hgft » Wed Feb 29, 2012 10:01 am

Coach Outlet Online Sale is with imperfections which consist of cuts, scars, and scratches will exist, the grain in its organically grown problem has between one of the most considerable dietary fibers strength, and getting a last end result between one of the most considerable durability. The grain also has organically grown breathability, resulting in increased comfort using the path from the wearer.

Louis Vuitton Outlet could possibly be one of the most well-known is not necessarily one of the most ideal for you! possibly the most current quarter round shoulder bag with fluorescent color provides you a shine in the moment, desire to possess the urge to it immediately; But possibly your pores and skin color could possibly be the earth beside the handbag could possibly be one of the most make you fondle admiringly joker choice.

Louis Vuitton Outlet supply reduce, the weakening from the role, tiny haystack in slender whole body once more and again. the right way to purchase Louis Vuitton bags That's between the powerful cohesion when Cunningham lancelet find yourself isolated point, allow wind and bad weather insulation, yr pursuing year, pile of grass system earlier short increased grass blanketed with it or bi erosion.

Jennifer Garner and Ben Affleck are the proud parents of a newborn son! The 39-year-old actress gave birth to the couple's third child in Santa Monica, Calif., a source tells Us Weekly. The family's newest addition joins older sisters Violet, 6, and Seraphina, 3. “I would have thought [Ben] wanted a boy]. At first … I really thought so,” Jen, who kept the baby's gender under wraps, told Jay Leno last month.
hgft
Experienced Developer
Experienced Developer
 
Posts: 66
Joined: Tue Feb 28, 2012 9:11 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests