• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

java.lang.IllegalStateException

 
Ranch Hand
Posts: 87
1
Netbeans IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you think, what is the problem with this code?


ADT gives the error in the title.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you need to post the entire stack trace to get more help here.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There should be more information (like the line number) in the stack trace in the logcat output. Without knowing which line of code causes this we'd just be poking in the dark.
 
Kovacs Akos
Ranch Hand
Posts: 87
1
Netbeans IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Boswell wrote:I think you need to post the entire stack trace to get more help here.



Here is the full code:

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not the code - the stack trace of the error message.
 
Kovacs Akos
Ranch Hand
Posts: 87
1
Netbeans IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Not the code - the stack trace of the error message.



Sorry:
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hm, not sure if the line numbers of the exception correspond with the line numbers of the code as shown here. Which of the toasts are shown?
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This looks like the likely culprit:

10-22 05:49:38.147: E/AndroidRuntime(333): Caused by: java.lang.ClassCastException: android.widget.RelativeLayout

But I agree with Ulf, the line numbers don't match up.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think it matters which line actually causes the exception, several lines in the method do the same thing: cast the view passed to the method to a TextView. Apparently the view passed in is actually a RelativeLayout, not a TextView and so can't be cast that way.

The view gets passed in from dont(), but we can't tell from this code where dont() gets the view - all we know is that the view is not a TextView as expected. You need to figure out where the view comes from and why it is a RelativeLayout rather than the expected type.
 
Kovacs Akos
Ranch Hand
Posts: 87
1
Netbeans IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:I don't think it matters which line actually causes the exception, several lines in the method do the same thing: cast the view passed to the method to a TextView. Apparently the view passed in is actually a RelativeLayout, not a TextView and so can't be cast that way.

The view gets passed in from dont(), but we can't tell from this code where dont() gets the view - all we know is that the view is not a TextView as expected. You need to figure out where the view comes from and why it is a RelativeLayout rather than the expected type.




The Textviews are on a RelativeLayout layout.
Toasts are working after clicking on the textviews.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kovacs Akos wrote:The Textviews are on a RelativeLayout layout.


That doesn't answer Steve's question of where that "View v" comes from that you're passing into the "dont" method. If that's a RelativeLayout object, that would explain what's happening.
 
Kovacs Akos
Ranch Hand
Posts: 87
1
Netbeans IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The onclicklistener was earlier in RelativeLayout, so yes that causes the error. Now I have move it to each textviews, one of them look like this:


Thanks, I have found the source of this problem.
 
Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic