问题
I need to create ListView with Fragment at my Sample Screen Shot View.
Screen Shots are
I know it is possible. But how do workout this types of Fragment at dynamically.
I have no idea. In this question and answers are very valuable me. Please give my solutions.
If I have mistaken for my question sorry.
回答1:
This answer is for those who all searching the answer for same question. The answer is achieved by FragmentManager and FragmentTransaction with the following syntax.
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
then you need to add your fragment to this fragmentTransaction with the following syntax.
fragmentTransaction.replace(R.id.detailFragment, layout1);
And finally you MUST commit your transaction. Otherwise changes will not persist.
fragmentTransaction.commit();
For brief example see this blog post. I hope This will help you.
Thank you.
回答2:
I suggest you read this article : here And then take a look at this example : here
来源:https://stackoverflow.com/questions/11901864/create-listview-with-fragment-at-dynamically-in-android