Question: smoothScrollTo?
Could you please add smoothScrollTo method in your Demo code?
I changed the followings in your demo code:
- change item width to 100px in view1.xml
- I want to scroll to the 31th item, so in the MainActivity.java added the following line at the end of onCreate method, then the scroll bar is empty now.
mList.smoothScrollTo(30*100);
I tried something similar and it looks like it's not working as expected. I tried smooth scrolling to item 132 in my list but it actually goes to item 98 (all items are the same width of 100px) and the scroll actually doesn't happen. It seems to get stuck on item 0 and then all of a sudden it shows item 98 and surroundings.
you must smoothScroll with the amount of pixels to scroll, not the item you want to show. ps. are you using the "development" branch?
I'm calling it like
mList.scrollTo(index*100);
where index is the position and 100 is the width of the item view in pixels.
I'm using the master branch.
Try switching to the development branch. It works there. Btw I will update the demo app also On May 22, 2013 11:51 AM, "Valerio Santinelli" [email protected] wrote:
I'm calling it like
mList.scrollTo(index*100);
where index is the position and 100 is the width of the item view in pixels.
I'm using the master branch.
— Reply to this email directly or view it on GitHubhttps://github.com/sephiroth74/HorizontalVariableListView/issues/9#issuecomment-18287899 .
The development branch doesn't even scroll close to the position now. It looks like it's not scrolling at all as it's stuck in position 0.
try to fetch again the dev branch, then in the MainActivity replace this code:
line 387: adapter.replace( last, getNextValue() );
with this: mList.smoothScrollTo( mList.getChildAt( 0 ).getWidth() * 10 );
the list will scroll to the 11° element
Ok, I just tried what you suggested, but it crashes with the following error:
05-24 10:12:53.038 918-918/it.sephiroth.android.sample.horizontalvariablelistviewdemo E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoSuchMethodError: it.sephiroth.android.library.widget.HorizontalVariableListView.postInvalidateOnAnimation
at it.sephiroth.android.library.widget.HorizontalVariableListView.smoothScrollBy(HorizontalVariableListView.java:2255)
at it.sephiroth.android.library.widget.HorizontalVariableListView.smoothScrollTo(HorizontalVariableListView.java:2241)
at it.sephiroth.android.sample.horizontalvariablelistviewdemo.MainActivity.onClick(MainActivity.java:387)
at android.view.View.performClick(View.java:3540)
at android.view.View$PerformClick.run(View.java:14167)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4560)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
ok, fixed it. btw just change that into postInvalidate() instead
Yes, it works this way. I'm going to try and bring the dev branch into my project and see if it works there as well ;) Thanks!
I tried with around 200 items in the scrollview and it hangs there for some seconds and then it doesn't scroll. But if I touch the view, it scrolls but not in the correct position.
I tried with scrollTo() instead, but it's pretty much the same.
Have you got any suggestion of what method I could use to just jump to a certain position?
yeah, the problem is that the list cannot scroll for more than its width within a single frame... I've added a temporary solution, checkout the latest developement branch. I've added also a demo in the MainActivity. But a better solution should be found on this.