firstVisibleItem, visibleItemCount, totalItemCount do not change even Scroll event happened

Im having a ScrollView which contains a Listview, However even if I scroll the listview, the three parameters in onscroll() method do not change, they remain the same as the initial state.

Here's my layout

Also my code for handling the scroll event,noted the contentlist is the listview not the scrollview.

However as you can see in the logcat, nothing change even if i scroll around and the visible item count should be two only

I wonder if its because of the height of the listview which cause this issue?

Thanks

Answers


First of all, i can't understand why you have kept a ListView inside a ScrollView.

You shouldn't put a ListView inside a ScrollView because the ListView class implements its own scrolling and it just doesn't receive gestures because they all are handled by the parent ScrollView.

But if you still need ListView inside the ScrollView , You can add touch listener to ListView and disable the touch event of the parent ScrollView like this..

contentList.setOnTouchListener(new OnTouchListener() {
    // Setting on Touch Listener for handling the touch inside ScrollView
    @Override
    public boolean onTouch(View v, MotionEvent event) {
    // Disallow the touch request for parent scroll on touch of child view
    v.getParent().requestDisallowInterceptTouchEvent(true);
    return false;
    }
});

Hope it helps.. :)


Having ListView inside of a ScrollView always cause problems.. Why don't you just have the ListView in the SwipeRefreshLayout and use addHeaderView() to display your LinearLayout above it?


Need Your Help

Error in testing Caffe's Alexnet caffe model

deep-learning caffe conv-neural-network

I trained caffe's Alexnet model for testing with more efficient model. Since my training is for pedestrians my image size is 64 x 80 images. I made changes to prototxt files to match to my trained ...

Why are there such differnces in performance between a LINQ query vs. Advanced.LuceneQuery?

ravendb

There reason I ask is that I had been using the strongly typed version, but ran into the issue of it not being flexible enough, so I switched over to the AdvancedQuery.Luncene which did provide the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.