Show numbers in horizontal recyclerview with max 5 rows










0















Show dynamic list of numbers in horizontal scrolled recyclerview with max 5 rows. Numbers size depend on current weeks number. If current weeks number is 45, then there will be 45 items. I can show them as below (vertically increasing) with GridLayoutManager.



1 6 11 16 
2 7 12 17
3 8 13 18
4 9 14 19
5 10 15 20

<----------->


But I want them to be shown as below (horizontal increasing)



1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 24

<--------------->


Here just for simplicity I started numbers from 1. In real application numbers can start from 100 or 1000.



Edit



Now what I've.



enter image description here



As you can see numbers are decreased vertically. I want them to be decreased horizontally.



Below is my adapter



class SINumberAdapter(val context: Context, val list:List<String>): RecyclerView.Adapter<SINumberAdapter.NumberViewHolder>()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NumberViewHolder

val textView = TextView(parent.context)
textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)
val paddingInPixels = 5.toPx
textView.setPadding(paddingInPixels, paddingInPixels, paddingInPixels, paddingInPixels)
return NumberViewHolder(textView)


override fun getItemCount() = list.size

override fun onBindViewHolder(holder: NumberViewHolder, position: Int)
holder.view.text = list[position]


inner class NumberViewHolder(val view:TextView):RecyclerView.ViewHolder(view)
init
view.setOnClickListener












share|improve this question
























  • you can use RecyclerView grid layout for this purpose

    – Ali Ahmed
    Nov 12 '18 at 9:25











  • create an item for your recyclerview with 5 textviews and inflate them in horizontal orientation

    – Vivek Mishra
    Nov 12 '18 at 9:33











  • @VivekMishra How? Columns size can be from 1 to 11, rows maximum 5.

    – Bek
    Nov 12 '18 at 9:46











  • that's what I meant to say make your one row as one item of your recyclerview.

    – Vivek Mishra
    Nov 12 '18 at 9:48











  • @VivekMishra I already did so. But how to show them horizontally increasing or decreasing way.

    – Bek
    Nov 12 '18 at 10:13















0















Show dynamic list of numbers in horizontal scrolled recyclerview with max 5 rows. Numbers size depend on current weeks number. If current weeks number is 45, then there will be 45 items. I can show them as below (vertically increasing) with GridLayoutManager.



1 6 11 16 
2 7 12 17
3 8 13 18
4 9 14 19
5 10 15 20

<----------->


But I want them to be shown as below (horizontal increasing)



1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 24

<--------------->


Here just for simplicity I started numbers from 1. In real application numbers can start from 100 or 1000.



Edit



Now what I've.



enter image description here



As you can see numbers are decreased vertically. I want them to be decreased horizontally.



Below is my adapter



class SINumberAdapter(val context: Context, val list:List<String>): RecyclerView.Adapter<SINumberAdapter.NumberViewHolder>()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NumberViewHolder

val textView = TextView(parent.context)
textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)
val paddingInPixels = 5.toPx
textView.setPadding(paddingInPixels, paddingInPixels, paddingInPixels, paddingInPixels)
return NumberViewHolder(textView)


override fun getItemCount() = list.size

override fun onBindViewHolder(holder: NumberViewHolder, position: Int)
holder.view.text = list[position]


inner class NumberViewHolder(val view:TextView):RecyclerView.ViewHolder(view)
init
view.setOnClickListener












share|improve this question
























  • you can use RecyclerView grid layout for this purpose

    – Ali Ahmed
    Nov 12 '18 at 9:25











  • create an item for your recyclerview with 5 textviews and inflate them in horizontal orientation

    – Vivek Mishra
    Nov 12 '18 at 9:33











  • @VivekMishra How? Columns size can be from 1 to 11, rows maximum 5.

    – Bek
    Nov 12 '18 at 9:46











  • that's what I meant to say make your one row as one item of your recyclerview.

    – Vivek Mishra
    Nov 12 '18 at 9:48











  • @VivekMishra I already did so. But how to show them horizontally increasing or decreasing way.

    – Bek
    Nov 12 '18 at 10:13













0












0








0








Show dynamic list of numbers in horizontal scrolled recyclerview with max 5 rows. Numbers size depend on current weeks number. If current weeks number is 45, then there will be 45 items. I can show them as below (vertically increasing) with GridLayoutManager.



1 6 11 16 
2 7 12 17
3 8 13 18
4 9 14 19
5 10 15 20

<----------->


But I want them to be shown as below (horizontal increasing)



1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 24

<--------------->


Here just for simplicity I started numbers from 1. In real application numbers can start from 100 or 1000.



Edit



Now what I've.



enter image description here



As you can see numbers are decreased vertically. I want them to be decreased horizontally.



Below is my adapter



class SINumberAdapter(val context: Context, val list:List<String>): RecyclerView.Adapter<SINumberAdapter.NumberViewHolder>()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NumberViewHolder

val textView = TextView(parent.context)
textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)
val paddingInPixels = 5.toPx
textView.setPadding(paddingInPixels, paddingInPixels, paddingInPixels, paddingInPixels)
return NumberViewHolder(textView)


override fun getItemCount() = list.size

override fun onBindViewHolder(holder: NumberViewHolder, position: Int)
holder.view.text = list[position]


inner class NumberViewHolder(val view:TextView):RecyclerView.ViewHolder(view)
init
view.setOnClickListener












share|improve this question
















Show dynamic list of numbers in horizontal scrolled recyclerview with max 5 rows. Numbers size depend on current weeks number. If current weeks number is 45, then there will be 45 items. I can show them as below (vertically increasing) with GridLayoutManager.



1 6 11 16 
2 7 12 17
3 8 13 18
4 9 14 19
5 10 15 20

<----------->


But I want them to be shown as below (horizontal increasing)



1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 24

<--------------->


Here just for simplicity I started numbers from 1. In real application numbers can start from 100 or 1000.



Edit



Now what I've.



enter image description here



As you can see numbers are decreased vertically. I want them to be decreased horizontally.



Below is my adapter



class SINumberAdapter(val context: Context, val list:List<String>): RecyclerView.Adapter<SINumberAdapter.NumberViewHolder>()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NumberViewHolder

val textView = TextView(parent.context)
textView.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)
val paddingInPixels = 5.toPx
textView.setPadding(paddingInPixels, paddingInPixels, paddingInPixels, paddingInPixels)
return NumberViewHolder(textView)


override fun getItemCount() = list.size

override fun onBindViewHolder(holder: NumberViewHolder, position: Int)
holder.view.text = list[position]


inner class NumberViewHolder(val view:TextView):RecyclerView.ViewHolder(view)
init
view.setOnClickListener









android android-recyclerview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 10:18







Bek

















asked Nov 12 '18 at 9:23









BekBek

1,2302619




1,2302619












  • you can use RecyclerView grid layout for this purpose

    – Ali Ahmed
    Nov 12 '18 at 9:25











  • create an item for your recyclerview with 5 textviews and inflate them in horizontal orientation

    – Vivek Mishra
    Nov 12 '18 at 9:33











  • @VivekMishra How? Columns size can be from 1 to 11, rows maximum 5.

    – Bek
    Nov 12 '18 at 9:46











  • that's what I meant to say make your one row as one item of your recyclerview.

    – Vivek Mishra
    Nov 12 '18 at 9:48











  • @VivekMishra I already did so. But how to show them horizontally increasing or decreasing way.

    – Bek
    Nov 12 '18 at 10:13

















  • you can use RecyclerView grid layout for this purpose

    – Ali Ahmed
    Nov 12 '18 at 9:25











  • create an item for your recyclerview with 5 textviews and inflate them in horizontal orientation

    – Vivek Mishra
    Nov 12 '18 at 9:33











  • @VivekMishra How? Columns size can be from 1 to 11, rows maximum 5.

    – Bek
    Nov 12 '18 at 9:46











  • that's what I meant to say make your one row as one item of your recyclerview.

    – Vivek Mishra
    Nov 12 '18 at 9:48











  • @VivekMishra I already did so. But how to show them horizontally increasing or decreasing way.

    – Bek
    Nov 12 '18 at 10:13
















you can use RecyclerView grid layout for this purpose

– Ali Ahmed
Nov 12 '18 at 9:25





you can use RecyclerView grid layout for this purpose

– Ali Ahmed
Nov 12 '18 at 9:25













create an item for your recyclerview with 5 textviews and inflate them in horizontal orientation

– Vivek Mishra
Nov 12 '18 at 9:33





create an item for your recyclerview with 5 textviews and inflate them in horizontal orientation

– Vivek Mishra
Nov 12 '18 at 9:33













@VivekMishra How? Columns size can be from 1 to 11, rows maximum 5.

– Bek
Nov 12 '18 at 9:46





@VivekMishra How? Columns size can be from 1 to 11, rows maximum 5.

– Bek
Nov 12 '18 at 9:46













that's what I meant to say make your one row as one item of your recyclerview.

– Vivek Mishra
Nov 12 '18 at 9:48





that's what I meant to say make your one row as one item of your recyclerview.

– Vivek Mishra
Nov 12 '18 at 9:48













@VivekMishra I already did so. But how to show them horizontally increasing or decreasing way.

– Bek
Nov 12 '18 at 10:13





@VivekMishra I already did so. But how to show them horizontally increasing or decreasing way.

– Bek
Nov 12 '18 at 10:13












1 Answer
1






active

oldest

votes


















1














Edited answer



Assuming that max column size is fixed or will be known before setting the adapter.



following global declarations



int maxColumn = 8;
int spanCount = 1;
String list = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20";


inside onCreate



spanCount = list.length / maxColumn + 1;

mGridLayoutManager = new GridLayoutManager(mContext, spanCount, GridLayoutManager.HORIZONTAL, false);


above I calculated the required span size for a given length of array and number of column



sample adapter code



private class MyAdapter extends RecyclerView.Adapter<MyHolder> 

int firstRowPos = 0;

@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
return new MyHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_item, null));


@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)

if (position % spanCount == 0)
firstRowPos = position;
holder.txtView.setText(list[position / spanCount]);
else
if (((position - firstRowPos) * maxColumn + position / spanCount) < list.length)
holder.txtView.setText(list[(position - firstRowPos) * maxColumn + position / spanCount]);
else
holder.txtView.setText("");



@Override
public int getItemCount()
return spanCount * maxColumn;




in adapter total count is returned as product of number of columns and number of rows (calculated span size)



now assume a grid of size column x row
write down the position of the elements in each cell as you want (going horizontally in your case), for example below



0 1 2 3 4
5 6 7 8


but the arrangement in recycler view will be as



0 2 4 6 8
1 3 5 7


from here you just need to figure out the formula which will be a function of position, row number, column number



that formula for 0th row is - all those positions which are integral multiple of total row count (span size)



for all other rows, it's



(position - (position from first row & that column)) x number of columns + calculated position from first row & that column which was used to fill the first row



sample (based on above example)
at 5th position in adapter, 7th position from data array has to sit, so
(5 - 4) x 5(column count) + 2 (from required first row) = 7



Care has to be taken though for the places where the above formula gives values more than array length



Output screen shot
output image






share|improve this answer

























  • How to show this [ "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", "836" ]

    – Bek
    Nov 12 '18 at 11:15











  • As I said items must be horizontally scrolled not vertically.

    – Bek
    Nov 12 '18 at 11:18











  • @Bek, edited/changed my answer. hope this helps

    – Kaustuv
    Nov 12 '18 at 16:06










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259119%2fshow-numbers-in-horizontal-recyclerview-with-max-5-rows%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Edited answer



Assuming that max column size is fixed or will be known before setting the adapter.



following global declarations



int maxColumn = 8;
int spanCount = 1;
String list = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20";


inside onCreate



spanCount = list.length / maxColumn + 1;

mGridLayoutManager = new GridLayoutManager(mContext, spanCount, GridLayoutManager.HORIZONTAL, false);


above I calculated the required span size for a given length of array and number of column



sample adapter code



private class MyAdapter extends RecyclerView.Adapter<MyHolder> 

int firstRowPos = 0;

@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
return new MyHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_item, null));


@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)

if (position % spanCount == 0)
firstRowPos = position;
holder.txtView.setText(list[position / spanCount]);
else
if (((position - firstRowPos) * maxColumn + position / spanCount) < list.length)
holder.txtView.setText(list[(position - firstRowPos) * maxColumn + position / spanCount]);
else
holder.txtView.setText("");



@Override
public int getItemCount()
return spanCount * maxColumn;




in adapter total count is returned as product of number of columns and number of rows (calculated span size)



now assume a grid of size column x row
write down the position of the elements in each cell as you want (going horizontally in your case), for example below



0 1 2 3 4
5 6 7 8


but the arrangement in recycler view will be as



0 2 4 6 8
1 3 5 7


from here you just need to figure out the formula which will be a function of position, row number, column number



that formula for 0th row is - all those positions which are integral multiple of total row count (span size)



for all other rows, it's



(position - (position from first row & that column)) x number of columns + calculated position from first row & that column which was used to fill the first row



sample (based on above example)
at 5th position in adapter, 7th position from data array has to sit, so
(5 - 4) x 5(column count) + 2 (from required first row) = 7



Care has to be taken though for the places where the above formula gives values more than array length



Output screen shot
output image






share|improve this answer

























  • How to show this [ "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", "836" ]

    – Bek
    Nov 12 '18 at 11:15











  • As I said items must be horizontally scrolled not vertically.

    – Bek
    Nov 12 '18 at 11:18











  • @Bek, edited/changed my answer. hope this helps

    – Kaustuv
    Nov 12 '18 at 16:06















1














Edited answer



Assuming that max column size is fixed or will be known before setting the adapter.



following global declarations



int maxColumn = 8;
int spanCount = 1;
String list = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20";


inside onCreate



spanCount = list.length / maxColumn + 1;

mGridLayoutManager = new GridLayoutManager(mContext, spanCount, GridLayoutManager.HORIZONTAL, false);


above I calculated the required span size for a given length of array and number of column



sample adapter code



private class MyAdapter extends RecyclerView.Adapter<MyHolder> 

int firstRowPos = 0;

@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
return new MyHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_item, null));


@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)

if (position % spanCount == 0)
firstRowPos = position;
holder.txtView.setText(list[position / spanCount]);
else
if (((position - firstRowPos) * maxColumn + position / spanCount) < list.length)
holder.txtView.setText(list[(position - firstRowPos) * maxColumn + position / spanCount]);
else
holder.txtView.setText("");



@Override
public int getItemCount()
return spanCount * maxColumn;




in adapter total count is returned as product of number of columns and number of rows (calculated span size)



now assume a grid of size column x row
write down the position of the elements in each cell as you want (going horizontally in your case), for example below



0 1 2 3 4
5 6 7 8


but the arrangement in recycler view will be as



0 2 4 6 8
1 3 5 7


from here you just need to figure out the formula which will be a function of position, row number, column number



that formula for 0th row is - all those positions which are integral multiple of total row count (span size)



for all other rows, it's



(position - (position from first row & that column)) x number of columns + calculated position from first row & that column which was used to fill the first row



sample (based on above example)
at 5th position in adapter, 7th position from data array has to sit, so
(5 - 4) x 5(column count) + 2 (from required first row) = 7



Care has to be taken though for the places where the above formula gives values more than array length



Output screen shot
output image






share|improve this answer

























  • How to show this [ "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", "836" ]

    – Bek
    Nov 12 '18 at 11:15











  • As I said items must be horizontally scrolled not vertically.

    – Bek
    Nov 12 '18 at 11:18











  • @Bek, edited/changed my answer. hope this helps

    – Kaustuv
    Nov 12 '18 at 16:06













1












1








1







Edited answer



Assuming that max column size is fixed or will be known before setting the adapter.



following global declarations



int maxColumn = 8;
int spanCount = 1;
String list = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20";


inside onCreate



spanCount = list.length / maxColumn + 1;

mGridLayoutManager = new GridLayoutManager(mContext, spanCount, GridLayoutManager.HORIZONTAL, false);


above I calculated the required span size for a given length of array and number of column



sample adapter code



private class MyAdapter extends RecyclerView.Adapter<MyHolder> 

int firstRowPos = 0;

@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
return new MyHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_item, null));


@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)

if (position % spanCount == 0)
firstRowPos = position;
holder.txtView.setText(list[position / spanCount]);
else
if (((position - firstRowPos) * maxColumn + position / spanCount) < list.length)
holder.txtView.setText(list[(position - firstRowPos) * maxColumn + position / spanCount]);
else
holder.txtView.setText("");



@Override
public int getItemCount()
return spanCount * maxColumn;




in adapter total count is returned as product of number of columns and number of rows (calculated span size)



now assume a grid of size column x row
write down the position of the elements in each cell as you want (going horizontally in your case), for example below



0 1 2 3 4
5 6 7 8


but the arrangement in recycler view will be as



0 2 4 6 8
1 3 5 7


from here you just need to figure out the formula which will be a function of position, row number, column number



that formula for 0th row is - all those positions which are integral multiple of total row count (span size)



for all other rows, it's



(position - (position from first row & that column)) x number of columns + calculated position from first row & that column which was used to fill the first row



sample (based on above example)
at 5th position in adapter, 7th position from data array has to sit, so
(5 - 4) x 5(column count) + 2 (from required first row) = 7



Care has to be taken though for the places where the above formula gives values more than array length



Output screen shot
output image






share|improve this answer















Edited answer



Assuming that max column size is fixed or will be known before setting the adapter.



following global declarations



int maxColumn = 8;
int spanCount = 1;
String list = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20";


inside onCreate



spanCount = list.length / maxColumn + 1;

mGridLayoutManager = new GridLayoutManager(mContext, spanCount, GridLayoutManager.HORIZONTAL, false);


above I calculated the required span size for a given length of array and number of column



sample adapter code



private class MyAdapter extends RecyclerView.Adapter<MyHolder> 

int firstRowPos = 0;

@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
return new MyHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_item, null));


@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position)

if (position % spanCount == 0)
firstRowPos = position;
holder.txtView.setText(list[position / spanCount]);
else
if (((position - firstRowPos) * maxColumn + position / spanCount) < list.length)
holder.txtView.setText(list[(position - firstRowPos) * maxColumn + position / spanCount]);
else
holder.txtView.setText("");



@Override
public int getItemCount()
return spanCount * maxColumn;




in adapter total count is returned as product of number of columns and number of rows (calculated span size)



now assume a grid of size column x row
write down the position of the elements in each cell as you want (going horizontally in your case), for example below



0 1 2 3 4
5 6 7 8


but the arrangement in recycler view will be as



0 2 4 6 8
1 3 5 7


from here you just need to figure out the formula which will be a function of position, row number, column number



that formula for 0th row is - all those positions which are integral multiple of total row count (span size)



for all other rows, it's



(position - (position from first row & that column)) x number of columns + calculated position from first row & that column which was used to fill the first row



sample (based on above example)
at 5th position in adapter, 7th position from data array has to sit, so
(5 - 4) x 5(column count) + 2 (from required first row) = 7



Care has to be taken though for the places where the above formula gives values more than array length



Output screen shot
output image







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 '18 at 16:17

























answered Nov 12 '18 at 11:08









KaustuvKaustuv

55129




55129












  • How to show this [ "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", "836" ]

    – Bek
    Nov 12 '18 at 11:15











  • As I said items must be horizontally scrolled not vertically.

    – Bek
    Nov 12 '18 at 11:18











  • @Bek, edited/changed my answer. hope this helps

    – Kaustuv
    Nov 12 '18 at 16:06

















  • How to show this [ "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", "836" ]

    – Bek
    Nov 12 '18 at 11:15











  • As I said items must be horizontally scrolled not vertically.

    – Bek
    Nov 12 '18 at 11:18











  • @Bek, edited/changed my answer. hope this helps

    – Kaustuv
    Nov 12 '18 at 16:06
















How to show this [ "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", "836" ]

– Bek
Nov 12 '18 at 11:15





How to show this [ "792", "793", "794", "795", "796", "797", "798", "799", "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", "830", "831", "832", "833", "834", "835", "836" ]

– Bek
Nov 12 '18 at 11:15













As I said items must be horizontally scrolled not vertically.

– Bek
Nov 12 '18 at 11:18





As I said items must be horizontally scrolled not vertically.

– Bek
Nov 12 '18 at 11:18













@Bek, edited/changed my answer. hope this helps

– Kaustuv
Nov 12 '18 at 16:06





@Bek, edited/changed my answer. hope this helps

– Kaustuv
Nov 12 '18 at 16:06

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259119%2fshow-numbers-in-horizontal-recyclerview-with-max-5-rows%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo