I tried to create Grid Layout for this I used below code. But in that code I don't know what is ItemView and how to implement it. When I put this code in my project I get error can not resolve symbol "ItemView". I got this code from below link -
https://stackoverflow.com/a/36143314/5726392
public class PrivateSeatViews extends FrameLayout implements View.OnClickListener {
        private GridLayout mGridView;
        private int mRowsCount;
        private int mColsCount;
        private int mCellSpace;
        private OnItemClickListener mOnItemClickListener;
        public PrivateSeatViews(Context context) {
            super(context);
            init(context, null);
        }
        // other constructors
        private void init(Context context, AttributeSet attrs) {
            // default values
            View layout = inflate(getContext(), R.layout.grid_layout, null);
            mGridView = (GridLayout) layout.findViewById(R.id.Lower);
            mGridView.setRowCount(mRowsCount);
            mGridView.setColumnCount(mColsCount);
            mGridView.post(new Runnable() {
                @Override
                public void run() {
                    int width = getMeasuredWidth() / getColumnsCount();
                    int height = getMeasuredHeight() / getRowsCount();
                    for (int i = 0; i < getRowsCount(); i++) {
                        for (int j = 0; j < getColumnsCount(); j++) {
                            GridLayout.LayoutParams params = (GridLayout.LayoutParams) getChildAt(i, j).getL;
                            params.width = width;
                            params.height = height;
                            getChildAt(i, j).setLayoutParams(params);
                        }
                    }
                }
            });
            addView(layout);
        }
        // this method allows to dinamically create grid
        public void buildChildren(int rowsCount, int colsCount) {
            mRowsCount = rowsCount;
            mColsCount = colsCount;
            mGridView.setRowCount(mRowsCount);
            mGridView.setColumnCount(mColsCount);
            buildChildren();
        }
        public void buildChildren() {
            for (int i = 0; i < getRowsCount(); i++) {
                for (int j = 0; j < getColumnsCount(); j++) {
                    ItemView1 view = new ItemView1(getContext(), i, j);
                    view.setOnClickListener(this);
                    mGridView.addView(view);
                }
            }
        }
        public void setOnItemClickListener(OnItemClickListener listener) {
            mOnItemClickListener = listener;
        }
        public ItemView getChildAt(int rowIndex, int columnIndex) {
            int index = (getColumnsCount() * rowIndex) + columnIndex;
            return (ItemView) mGridView.getChildAt(index);
        }
        public boolean isTouchOn(int rowIndex, int columnIndex) {
            return getChildAt(rowIndex, columnIndex).isTouchOn();
        }
        public int getColumnsCount() {
            return mGridView.getColumnCount();
        }
        public int getRowsCount() {
            return mGridView.getRowCount();
        }
        @Override
        public void onClick(View v) {
            if (v instanceof ItemView) {
                ItemView view = (ItemView) v;
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.onItemClick(view);
                }
            }
        }
        public interface OnItemClickListener {
            void onItemClick(ItemView view);
        }
    }
 
     
    