4

New to android java and trying to figure this out. If I want to have an array adapter to display a list of images horizontally, what options do I have other than RecyclerView?

Basically, I am making a Chinese mahjong game. I want to display thumbnails horizontally that needs onClickListener functionality. The screen needs to NOT be scrollable. A LinearLayout doesn't seem to have an arrayadapter.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
  • Does this answer your question? [Remove RecyclerView scroll effects](https://stackoverflow.com/questions/27724923/remove-recyclerview-scroll-effects) – Biscuit May 03 '20 at 09:36
  • @Biscuit that question addresses specifically removing the overscroll glow effect, which, while similar, is not quite the same as the issue here. – Ryan M May 03 '20 at 10:18
  • Have you checked this? https://stackoverflow.com/questions/30531091/how-to-disable-recyclerview-scrolling – momvart May 03 '20 at 10:25
  • 3
    Does this answer your question? [How to disable RecyclerView scrolling?](https://stackoverflow.com/questions/30531091/how-to-disable-recyclerview-scrolling) – momvart May 03 '20 at 10:26

2 Answers2

0

No Layout has something similar to the arrayadapter, if the amount of images don't change I would suggest putting them inside of a layout as you mentioned and reference the seperate imageviews seperately

Alternatively, if the amount is dynamic I'd suggest using a ListView but disabling scrolling, for example using this:

listView.setOnTouchListener(new OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {
        return (event.getAction() == MotionEvent.ACTION_MOVE);
    }
});
Merthan Erdem
  • 5,598
  • 2
  • 22
  • 29
0

You can actually use RecyclerView for this (assuming you have a new enough version, though it's supported this for a couple years now)

You'd just need to create a horizontal RecyclerView and set its android:layout_width to "wrap_content". That will cause it to inflate all of the available items and then size itself to their total width.

Ryan M
  • 18,333
  • 31
  • 67
  • 74