• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error cannot be cast to android.app.Activity

 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • 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
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post your logcat?
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • 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
  • 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: 79
  • Mark post as helpful
  • send pies
  • 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?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 79
  • Mark post as helpful
  • send pies
  • 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: 42969
73
  • Mark post as helpful
  • send pies
  • 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: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thank you

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

regards
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic