0

I have ViewPager of fragments and every fragment contains GridView. The issue I am facing is ViewPager calls getView of GridView adapter many times. I want to change GridView item views but multiple calls is creating issue in logic. Is there any way to block multiple calls or Is there any event that FragmentPagerAdapter has created all fragments, then I send broadcast to all fragments to view changes?

UPDATE

if(AppPreferences.getString(AppPreferenceKeys.EDIT_INVOICE_NUMBER, "").length() > 0) {
                int quantity = ((MainActivity) context).getQuantity(menu.getMenuCode() + "");
                if (quantity > 0) {
                    holder.cv_menu.findViewById(R.id.rl_cv_menu).setBackgroundColor(context.getResources().getColor(R.color.accepted));
                    for (int i = 0; i < quantity; i++) {
//                        holder.cv_menu.performClick();
                        handleMenuItemClick(holder.cv_menu);
                    }
                }
            }
halfer
  • 19,824
  • 17
  • 99
  • 186
Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
  • If "multiple calls is creating issue in logic", then you're not implementing your `Adapter` correctly. – Mike M. Jun 09 '16 at 08:14
  • @PiyushGupta: Please see the updated post. I want to change the background color of gridview item. but only last item is updated. – Mustansar Saeed Jun 09 '16 at 08:17
  • Try this http://stackoverflow.com/questions/18341779/preload-fragments-view-in-viewpager-on-first-run – dindinii Jun 09 '16 at 08:18

0 Answers0