-1

I've a "A" fragment as follows (recyclerview): https://img.exs.lv/e/z/ezeliitis/frags.png

  1. How should I effectively duplicate fragment "A" with different images/text (same layout) and make fragment "B"?
  2. How should I implement Database information and storage? For instance, I'll have fragments "A" category - 'GAMES'. When I click it, it should transfer to duplicate fragment "B", where it has "Basketball", "Football" ect... Also. If I click the fragments picture, it should show a small square with short information. Should I just make 3 seperate tables? How to link Fragments A - Fragment B - Detail information?
  3. Also, if I've categories in Fragment "A" as following: cars/food/girls and I click food, then it goes to Fragment "B" which holds pizza/drinks ect - how to make sure fragment B gives right information according to fragment A (make sure it doesnt give from fragment 'a' (food) a result of fragment 'b' which holds information about cars for instance, which would be wrong)?
Cœur
  • 37,241
  • 25
  • 195
  • 267
JasonM
  • 3
  • 6

1 Answers1

-1

You can use manual constructors for passing data from fragment A to fragment B.

public class fragB extends Fragment{

    int type;

    public fragB(){
        this.type = DEFAULT_TYPE;
    }

    public fragB(int type){
        this.type = type;
    }
}

From fragment A do this to define your fragB

Fragment f = new fragB(TYPE_CAR);

or

Fragment f = new fragB(TYPE_FOOD);

Note: Empty constructor is just for resolving exception.

Aman
  • 23
  • 8