Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Error: onclick method  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys im stuck with this




and with this code i have the error

   java.lang.IllegalStateException: Could not execute method for android:onClick
 
Ranch Hand
Posts: 55
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the whole stack trace? "Could not execute method for android:onClick" does not say much
 
German Hernandez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E/AndroidRuntime: FATAL EXCEPTION: main
Process: asd.testapp, PID: 6822
java.lang.IllegalStateException: Could not find method onClick(View) in a parent or ancestor Context for android:eek:nClick attribute defined on view class android.support.v7.widget.AppCompatImageView with id 'select1'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:424)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:381)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

and the complete code in paste
https://pastebin.com/6Fz6d4w1


thanks
 
Ranch Hand
Posts: 172
1
Android Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
post xml as well
 
German Hernandez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i fix that but im fighting with this, no error but when i tap on the image don't change to the other

actual code:


stackoverflow.com/questions/8642823/using-setimagedrawable-dynamically-to-set-image-in-an-imageview
in SO one user suggest this line

int id = getResources().getIdentifier("asd.testapp:drawable/" + oldpic, null, null); << but i get a "cannot resolve on the variable oldpic (its the name of the first image)
 
Randy Tong
Ranch Hand
Posts: 172
1
Android Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add toast to check is the getTag value you get is execute in the correct condition?
 
German Hernandez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i test this



and still nothing
 
Randy Tong
Ranch Hand
Posts: 172
1
Android Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value displayed in toast is in the correct condition ? Did the value you get is what you expected ?
 
German Hernandez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get the message, so the image is listening and working but the image not change

its simple i have one image "image1", when the user click on it i change to "image2"

but now i click and not change xD
 
Randy Tong
Ranch Hand
Posts: 172
1
Android Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try clear the image in ImageView before you set to another image
 
German Hernandez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
randy i try but i think the problem is with the logic of the tags
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!