Reputation: 79
i want to reuse my videoview to another fragment but for that i need to remove videoview first, from parent view then i can add view,but i want to reuse videoview in another fragment without removing it from parent view.is it possible ?
if (videoView.getParent() != null) {
((ViewGroup) videoView.getParent()).removeView(videoView);
rel_view.addView(videoView, params);
}
in above code snippet i am removing parent videoview first and than add view to fragment but i want function as like above description please help.
Upvotes: 1
Views: 598
Reputation: 31
No. A View instance can have only one parent.
To acheive similar views in two parents, you can create two instances of the view by inflating the layout.
You can create an instance of the view by the following code:
View v = getLayoutInflater().inflate(R.layout.<your_view_layout>, null)
and then adding the view instance to the required parents.
Upvotes: 2