Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Fragment not following parent activity?

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I really hope anyone can help me. I'm busting my head for daaays.

I have a simple MainActivity, with activity_main.xml, which has a DrawerLayout (which shows nicely) and FrameLayout (which is intended for Fragment). Both DrawerLayout and FrameLayout are childrens of simple LinearLayout.

Now, once I start my simple app from phone/emulator, weird thing happen. First, activity appears (as expected) and then Fragment appears but with small delay. So I have to press back button two times in order to get out of the app, even tho I explicitly said to FragmentManager no to put Fragement on the back stack.

My main goal for this demo exercise is to show Fragement (which has couple of Cinema objects through RecyclerView) from within activity. Key idea is to use that FrameLayout (fragment_container) and through it to display fragment's view. (I don't know if this is possible or maybe this is the place where mistake is hidding) And I want Drawer to be present, but froM Activity. Like I said, I did succeed to display, through RecyclerView, those Cinema object (stored in some Singleton helper class). Now, I have to press two times Back to get out of the app, don't want that.

Here is code.



FragmentTransition class (I could have posted right there in MainActivity, but our TA told us to do it this way)




XML for MainActivity



Here is the Fragment from the beginning of the post, I called it CinemaListFragment



And finally code for simple RecyclerView for this Fragement (fragement_cinema_list):



I apologize for this long code post. If necessary, I could send zip of the project. It is not big, simple student exercise.

Lets go Ranchers
 
Rancher
Posts: 458
7
Android Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the issue fixed?
 
Mike Gosling
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope...
 
Randy Tong
Rancher
Posts: 458
7
Android Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You miss to paste Cinema class and DrawerListAdapter. Consider post it in git, so we can clone it down and test.
 
Mike Gosling
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Randy,

Here is link to GitHub project.
 
I found a beautiful pie. And a tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic