Rest menu is android with multiple tabs hav diff data & updating the count in row of the listview?

47 views Asked by At

I have to create a restaurant menu in android with tabs (Soups,Starters) , that means the there are multiple fragments of tabs with same fragment layout having one adapter & different data. I want to increament quantity of item, so i have added one counter valiable in model data . Question is As I increament my counter in 1st tab of listview it gets reflected in second tab also as adapter is same. Kindly give solution ?

   //ViewPager Code, Sending Data 
   @Override
    public Fragment getItem(int position) {
        Bundle b = new Bundle();
        b.putParcelable("items",newfoMenuCatsUtils.get(position));
        foMenuListFragment= new FOMenuListFragment();
        foMenuListFragment.setArguments(b);
        return foMenuListFragment;

    }

    //To fragment , From fragment to adapter now u can see
     //    newfoMenuCatsUtils.get(position) is giving different data
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState){

    view = inflater.inflate(R.layout.fo_menu_list, container, false);
    this.inflater=inflater;
    listView= (ListView) view.findViewById(R.id.listview);
    progressBar = (ProgressBar) view.findViewById(R.id.progress1);
    txtMsg = (TextView) view.findViewById(R.id.txtMsg);
    errorTxtMsg= (TextView) view.findViewById(R.id.errortxtMsg);
    layout_progress = (LinearLayout) view.findViewById(R.id.linearLayout);
    layout_progress.setVisibility(View.GONE);
    Bundle b = getArguments();
    foMenuCatsUtil = b.getParcelable("items");
    foMenuAdapter=new FoMenuAdapter(getActivity(),foMenuCatsUtil.getItems(),this);
    listView.setAdapter(foMenuAdapter);

    return view;}   
1

There are 1 answers

0
saurabh169 On

Please specify how and what data you are sending to your 'same' adapter...please post some code...about where you are setting up the data and the adapter. Because unless data you are feeding to your adapter is also same, adding an counter variable for one fragment should not affect data of other fragment.