java - Android Studio error - Inconvertible types, Cannot cast Fragment -


enter image description heretrying make simple program using fragments. exact error :

"inconvertible types, cannot cast android.app.fragment com.example.something.something.workoutdetailfragment" 

code:

public class mainactivity extends activity {       @override      protected void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);          setcontentview(r.layout.activity_main);           workoutdetailfragment frag = (workoutdetailfragment) getfragmentmanager().findfragmentbyid(r.id.detail_frag); //error!          frag.setworkoutid(1);      } 

}

(my activity_main_xml code)

your workoutdetailfragment should extends android.app.fragment, not android.support.v4.app.fragment. try out~


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -