Ivan Fazaniuk Ivan Fazaniuk - 13 days ago 5
Android Question

Android multi-level lists with sqlite

Structure of the application is:

enter image description here

Data is stored in SQLite DB. I see two 2 ways to accomplish it:

1) Create 3 separate activities for each Tab and put them as fragments

Question: how then I push a parameter for filtering to the next activity, for example Tab 1 received "Category 2", got the data from SQLite and showed it, then user swiped to Tab 2 ?

2) Put all Tabs data to 1 Activity and display filtered data in different views inside each tab

Question: is it possible?

Answer

It is possible both ways, for your first suggestion for implementation you can see here - Passing parameters from Android FragmentActivity to Fragment; and for the second suggestion, you can implement it...

your question is too general,

I recommand you to learn about FragmentActivity for start

EDIT after your comment: you can pass parameters to the fragment with Bundle, in example (let's assume that our fragment called LocationFragment):

public static LocationsFragment newInstance(String param1, String param2) {
    LocationsFragment fragment = new LocationsFragment();
    Bundle args = new Bundle();
    args.putString("prm1", param1);
    args.putString("prm2", param2);
    fragment.setArguments(args);
    return fragment;
}

and read the parameters like this (LocationFragment.java):

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        mParam1 = getArguments().getString("prm1");
        mParam2 = getArguments().getString("prm2");
    }
}

This is also explaind in the first link, you can pass the category and do whatever you need to do inside the onCreate of your fragment.