• 6

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

This question already has answers here:

For the RecycleView layouts in a grid form with different cell spans can be achieved by using the GridLayoutManager. You will find many tutorials in the internet about how to implement it.

GridLayoutManager  layoutManager = new GridLayoutManager(this, 6);

layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    public int getSpanSize(int position) {
        // Use whatever logic you need here to decide how 
        //  many columns to span for any given row position
        if (position % 2)
            return 3;
            return 6;

Then in onBindViewHolder update the LayoutParams.width of each view as you may require.

  • 1
Reply Report
      • 2
    • Then for such case is better to use a GridLayoutManager, and update the views metrics when binding them. So use the lookup to specify how many columns a row must span, and the onBindViewHolder to update the individual views metrics to render accordingly the required columns area.
      • 1
    • I also tried this earlier. This layout manager also required spanCount which problematic is because I do not know the count of both coloumns and rows.
    • getting Cannot resolve method 'setSpanSizeLookup(anonymous android.support.v7.widget.GridLayoutManager.SpanSizeLookup)` error.