N
N
Neonoviiwolf2017-03-12 11:34:54
Android
Neonoviiwolf, 2017-03-12 11:34:54

Fragment inflate - only the first Fragment is filled with data?

Good!
Probably better code first

@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_create_menu, container, false);

        LinearLayout layout = (LinearLayout) view.findViewById(R.id.testLin);
        for (int i = 0; i < 30; ++i) {
//Создаётся layout  с  карточками, тут всё нормально
//В layout лежит CardView, в CardView лужит LinearLayout, который ниже пытаюсь заполнить данными
            LinearLayout layoutCV = (LinearLayout) layout.inflate(layout.getContext(), R.layout.card_view, layout);
//полагаю проблема тут, этот Layout лежит в CardView
            LinearLayout layoutCardView = (LinearLayout) layoutCV.findViewById(R.id.layout_card_view);

            ItemMenu itemMenu = new ItemMenu();
//Данные появляются только в первой карточке, а я задумывал чтобы в каждом layoutCardView
            View view1 = itemMenu.onCreateView(inflater, layoutCardView, new Bundle());
            layoutCardView.addView(view1);
        }
        return view;
    }

In general, I want to fill all the CardView with data, but it turns out that all the data goes into the first card

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question