I have a single activity that displays different fragments instead of changing activities. In one fragment, I have a ListView where each item has a couple ImageViews and TextViews. When the user clicks on an ListView item, the activity switches fragments, but the new fragment will share all of the same Views as the ListView item, plus some more stuff added in that specific fragment.
Is there a way to pass views between fragments so I don’t have to inflate all the same views again? Would it be better to get the bitmaps and text strings from the Views in the list item and populate those into new Views in the new fragment?
Short answer to your question.
No there is not a way to share views between fragments unless both fragments will have the same layout.
A view is only a container that describes a layout in your application. It is up to you to manipulate data to fill the containers.
I do not think that you are trying to use the same view. I think that what you want is the data that was in the view in the list. You are going to have to deal with fragment to fragment communication. This involves setting up an interface and passing the data to your main activity and having your other fragment get that data from the activity when it is created. I put a link to a post i responded to. The code i posted uses fragments to display the applicaiton instead of activities. I left out a few fragments but the code for interfaces is there as well as some good links. If you have any questions about it let me know.
Fragment Demo Code