void updatePintrestView() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // inflate your activity layout here! sortingArray(); Layout1.removeAllViews(); Layout2.removeAllViews(); for (int i = 0; i < arrDataNote.size(); i++) { View contentView = inflater.inflate(R.layout.notefoldepintrestrow, null, false); TextView textViewSlideMenuName = (TextView) contentView.findViewById(R.id.textViewSlideMenuName); TextView textViewSlideMenuNameSubTitle = (TextView) contentView.findViewById(R.id.textViewSlideMenuNameSubTitle); View layoutsepreter = (View) contentView.findViewById(R.id.layoutsepreter); layoutsepreter.setVisibility(View.VISIBLE); SideMenuitems model = arrDataNote.get(i); textViewSlideMenuName.setText(model.getMenuName()); textViewSlideMenuNameSubTitle.setText(model.getMenuNameDetail()); if (i % 2 == 0) { Layout1.addView(contentView); contentView.setBackgroundColor(Color.parseColor(model.getColours())); } else { Layout2.addView(contentView); contentView.setBackgroundColor(Color.parseColor(model.getColours())); } } }