• 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
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Error cannot be cast to android.app.Activity

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm trying to change the code to use a sliding menu but i'm having problems

This is the error

12-16 13:09:56.272: E/AndroidRuntime(1176): Caused by: java.lang.ClassCastException: com.ebspma.activity.ReservasSalasFragment cannot be cast to android.app.Activity




I have already changed to getActivity() only and i'm still hving this error

Any help please?

Thanks
 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you post your logcat?
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Thank you for your help

This is the logcat



regrads
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Their is class cast exception you are casting Fragment to activity.

I am not able to figure out which line it is but you can do go on Logcat and click on this line.


Caused by: java.lang.ClassCastException: com.ebspma.activity.ReservasSalasFragment cannot be cast to android.app.Activity




this will take you to exact line where is error then post that line then we can figure out.


Reply if you not found your solution
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I did use the logcat but in that error i don't have any line error so i don't know where is the problem

any help?
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you doing in the app when this happens? How are you using this class?
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm pressing a button to move to my next class

Im moving from this class:



And i have that error as soon i click the button to move to another class

regards
 
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
Right: Context.startActivity starts an activity (no surprise there :-), so the Intent needs an Activity, not a Fragment,.
 
Gil Carvalho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thank you

So i do i call the fragment in this case??

regards
 
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
You'd replace the current layout with the new Fragment in a fragment transaction. See http://developer.android.com/training/basics/fragments/creating.html for an example of how to handle multiple fragments, both for the phone (one fragment) and tablet (two fragments) cases.
 
I didn't say it. I'm just telling you what this tiny ad said.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic