Android - Custom ListView disable scrolling - java

I have a custom ListView which checks for a value in its adapter, and if its false it should disable scrolling. The reason I need to do this is because inside the listview are rows of horizontal listviews (using this implementation: https://github.com/dinocore1/DevsmartLib-Android) and if you scroll slightly up or down whilst scrolling on of these horizontal views, they stop scrolling and the listview instead scrolls.
The issue with this code is that it doesn't always seem to prevent the listview from scrolling, and it also doesn't pass the action through to the child (horizontal listview) like I believe it should (passing false).
Does anyone have any idea how I can get it to stop scrolling and still pass the movement action through to the child? Any help would be appreciated.
Thanks.

Related

Why is Android setting "fastScrollEnabled" to false for both a Grid View and List View?

I've been having some trouble enabling fast scrolling for a Grid View and a List View. I've set fastScrollingEnabled="true" in their XML layouts and added both the horizontal and vertical state drawables for the track and thumb. I also added these values to their styles, as well, and have "[GridView | ListView].setFastScrollEnabled(true) set programmatically. However, when I run the application, fast scrolling does not work. After some investigation, I've noticed via Layout Inspector that the fastScrollEnabled attribute is set to "false" for both the Grid View and the List View. Why would Android automatically set this value back to false? Is there a way for me to prevent this so that I can fast scroll on these view types? I've gotten fast scrolling working on Recycler Views in the same application with the same amount of setup, but for some reason the Grid View and List View fast scrolling attribute remains false.

Controlling RecyclerView scroll from Seekbar

Is there any library or any way in which we can sync between the RecyclerView and the Seekbar.
By that I mean is that when I drag seekbar the items change, the seekbar width define the maximum scroll that the recycler can have. Similarly when I scroll the recyclerview the seekbar should update.
In short both should be in sync.
Or is there any other way to handle it.
What I am trying to achieve can be seen from the image attached to this question. Here top section is the seekbar and the bottom section is recyclerview.
Any solution or help is appreciated.
First of all, you can listen to the change of seek bar value by the setOnSeekBarChangeListener(). See get android seek bar value and display it on screen
.
Then, when seek bar value is changed, you can notify the recycler view to scroll to any position by the smoothScrollToPosition() of recycler view or smoothScrollToPosition() of linear layout manager

how to show selection of the lst item in recycler view in android?

I have implemented the recycler view in navigation drawer in android.This is working fine.I am able to switch between item by clicking on recycler view item.
but i am not able to change the background color for the selected item.please suggest me how to imeplement it.I have tried this so far.
1.Background Selector in RecyclerView Item
Tried to make recycler view clickable,focusable but didn't work
2.http://innodroid.com/blog/post/tracking-selected-item-in-recyclerview
implemented but didn't understand where to write the code for changing background
Please help me out.
What you really need to understand with RecyclerView is that it's not the same control as a Listview with a funky adapter.
RecyclerView does not exhibit many of the ListView's functionalities and whilst it's understandable to compare it to a ListView or a GridView (or event a StaggeredGridView), it shouldn't be confused with them.
With RecyclerView, the responsibilities of handling the "background change" selector relies on the underlying control that the RecyclerView is holding. It's also the same with onClick and many other perks you get for free in a ListView.
Why it is better (or worse) to use a RecyclerView to a ListView is a different matter that I won't go into but to fix your problem, in order to set a background selector on your RecyclerView, add this to the layout that you're inflating in your ViewHolder (i.e. the actual layout that's being used inside the RecyclerView, similar to your "list row item" that you would inflate inside an ArrayAdapter if it were a ListView):
android:clickable="true"
android:background="?android:selectableItemBackground"
Which should set the background appropriately.
Recycler view are recommend when you have very large items & wants to have a custom UI. If you want to display only few items the would recommend to use List View.

Horizontal listview with OnScrollListener

I need sync scroll of 2 listViews (vertical and horizontal)
I tried several libraries for the horizontal listview, but no library implements OnScrollListener()
https://github.com/MeetMe/Android-HorizontalListView
https://github.com/sephiroth74/HorizontalVariableListView
https://github.com/dinocore1/DevsmartLib-Android
need this callback to scroll vertical list when scoll the horizontal list...
how can I do this?
Thanks!!
I did a little bit of code for this exact thing a while back. Check it out here https://github.com/slightfoot/android-tandem-scroll
Just duplicate https://github.com/slightfoot/android-tandem-scroll/blob/master/Library/src/com/demondevelopers/tandemscroll/TandemScrollView.java file and make it extend HorizontalScrollView.

How to disable scrolling for ListView on Android?

I have the following question: I have a difficult layout that contain ListView. I need disable scrolling ability for ListView, because it's container (root Layout) have had ScrollView already, and I don't need a scrolls for ListView. I disable scrolls by android:scrollbars="none", but abilitity for scrolling would stay. I need that if ListView has 10 items that all items will be shown. How can I do it?
Can't you just use a LinearLayout with 10 elements instead of the ListView? It is not a good idea to have a ScrollView in another ScrollView.
Why do you still use the ListView? Create your own Layout for an item and load it several times (LayoutInflater, .addView(listItem)).

Categories