Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display a fragment inside the view? #170

Open
SeakyLuo opened this issue Dec 11, 2019 · 0 comments
Open

How to display a fragment inside the view? #170

SeakyLuo opened this issue Dec 11, 2019 · 0 comments

Comments

@SeakyLuo
Copy link

SeakyLuo commented Dec 11, 2019

The layout for my view is very simple:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/dialog_food_card_frame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:layout="@layout/fragment_food_card" />

I want to use the FrameLayout to display a fragment, so I tried this but it seems that the FragmentManager could not find the dialog_food_card_frame:

@NonReusable
@Animate(Animate.CARD_TOP_IN_DESC)
@Layout(R.layout.dialog_food_card)
public class FoodCard {
    private FoodCardFragment foodCardFragment = new FoodCardFragment();
    private Food food;
    private Fragment fragment;
    public FoodCard(Fragment fragment, Food food){
        this.fragment = fragment;
        this.food = food;
    }

    @Resolve
    public void onResolved() {
        fragment.getChildFragmentManager().beginTransaction().add(R.id.dialog_food_card_frame, foodCardFragment).commit();
        foodCardFragment.LoadFood(food);
    }
}

How do I display the fragment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant