Coder Social home page Coder Social logo

Comments (11)

johannilsson avatar johannilsson commented on May 27, 2024 2

I did notice that calling setSelection within onCreate had no effect even though this works fine using the standardl ListView. But this works fine in the example app;

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    setSelection(5);
}

If i remove the method onAttachedToWindow in PullToRefreshListView the call from onCreate works as expected. I can't remember why I needed to override onAttachedToWindow now though. But please test by removing that and if nothing else breaks or anyone else have any problem with removing that method I'm happy to do it.

from android-pulltorefresh.

yochiro avatar yochiro commented on May 27, 2024 1

I ran into the same problem, and after investigation I found out the issue, as explained below by Romain Guy https://groups.google.com/forum/?fromgroups=#!topic/android-developers/EnyldBQDUwE

I created a new method :

private void resetPosition() {
  this.post(new Runnable() {
    @Override
    public void run() {
      setSelection(1);
    }
  }
}

and replaced all references of setSelection(1) to resetPosition()

and it worked!

from android-pulltorefresh.

johannilsson avatar johannilsson commented on May 27, 2024

Thank you for the report. This is strange, it's using setSelection internally to hide the header. Will investigate.

from android-pulltorefresh.

 avatar commented on May 27, 2024

Hm worked for me. Could you try it in the test app ?

from android-pulltorefresh.

realjax avatar realjax commented on May 27, 2024

Great! Using it in the onCreate method was also where I ran into problems. I removed the onAttachToWindow method and now everything works fine. I could see no downsides or other affects from removing the method other then the list starting out with the 'touch to refresh' message being displayed by default. A setSelection(1) in my onCreate solved this.

Many thanks for your quick response!!

from android-pulltorefresh.

johannilsson avatar johannilsson commented on May 27, 2024

Ah that's why we needed it. Well then I don't want to remove it until that problem is solved. If you want to play around with it you can experiment by calling setSelection(1) from other places internally in the widget.

from android-pulltorefresh.

SlawpLabs avatar SlawpLabs commented on May 27, 2024

Hi guys.
I was having the same problem, and I also managed to fix it with your solution!
I simply had to remove the setSelection() call in the onAttachedToWindow() (or actually remove the onAttachedToWindow overriding).

Thanks guys.

Out of curiosity, do you remember why you called setSelection() in that method in the first place?

from android-pulltorefresh.

Arthur83 avatar Arthur83 commented on May 27, 2024

I have the same problem, anyone here can help me?

from android-pulltorefresh.

zeeshanaslam78 avatar zeeshanaslam78 commented on May 27, 2024

I am having the same problem in API 28 Pie. setSelection doesn't work on Pie and scrollTo works first time only but after going to next fragment and coming back to same fragment where I am using ListView, scrollTo doesn't work. So strange behavior on Pie.

from android-pulltorefresh.

johannilsson avatar johannilsson commented on May 27, 2024

Hi, this library is deprecated and there is no active development in it, please have a look at SwipeRefreshLayout for an alternative.

from android-pulltorefresh.

zeeshanaslam78 avatar zeeshanaslam78 commented on May 27, 2024

Oh Sorry wrong window

from android-pulltorefresh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.