有什么办法可以动态地将Fragment类设置为FrameLayout类吗?

时间:2020-05-05 09:09:12

标签: android-studio android-layout android-activity

我需要动态创建FrameLayouts并将动态的特定片段设置为布局。我们可以在android studio中做到吗?

for (int i = 0; i < list.size(); i++)
{
    User current_user = list.get(i);

    UserFragment current_user_fragment = new UserFragment(current_user);
    FrameLayout current_frame_layout = new FrameLayout(getContext());

    // then I need to the current_user_fragment into the current_frame_layout here 
}

注意:

我正在尝试动态创建以下XML层次结构;

-LinearLayout
    -LinearLayout
        -FrameLayout
        -FrameLayout
        -FrameLayout
        -FrameLayout
    -LinearLayout
        -FrameLayout
        -FrameLayout
        -FrameLayout
        -FrameLayout
        .
        .
        .

0 个答案:

没有答案