Imported PullToRefresh and write to the Layout

<com.handmark.pulltorefresh.library.PullToRefreshListView android:id="@+id/pull_to_refresh_listview" android:layout_height="fill_parent" android:layout_width="fill_parent" /> 

But for some reason the project flies. When you hover on this component writes

Cannot find declaration to go to

Tell me how to fix this error, can anyone come across?

  • How did you import this library? By the way, is the standard SwipeRefreshLayout not suitable? - s8am
  • No, it does not fit. I needed exactly BottomRefresLayout. Imported, File -> New -> Import Module - DevOma
  • Without libraries, it's like ???? - DevOma
  • With the help of Gradle, the campaign will not work ... There are no links - DevOma
  • 2
    ListView is an obsolete component that has been replaced by RecyclerView . However, as you wish. By the way, PullToRefreshListView from Chris Banes is also not supported for a long time. - s8am

1 answer 1

The author’s original task was to add items to the ListView when it was scrolled.

Let int mEventPosition be the number of the ListView element from the end, at the appearance of which it is necessary to perform some actions ( 0 is the last element, 1 is the penultimate and so on).

 public class MainActivity extends AppCompatActivity { private ListView mMyListView; private ArrayAdapter<String> mAdapter; private int mEventPosition; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mEventPosition = 0; mMyListView = (ListView) findViewById(R.id.my_list_view); mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new String[]{"one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one", "one"}); mMyListView.setAdapter(mAdapter); mMyListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) {} @Override public void onScroll(AbsListView absListView, int i, int i1, int i2) { if(mAdapter.getCount() - 1 - mMyListView.getLastVisiblePosition() == mEventPosition) Log.d("MY_TAG", "Your action"); } }); } } 

Please note that in the if in the onScroll method onScroll still need to add a check for the need to trigger it (now it is executed multiple times when scrolling on a given element ).

  • For some reason, when scrolling anywhere, D / MY_TAG: Your action - DevOma