令牌上的语法错误,预期AnnotationName在recyclerview中 - Android

时间:2016-11-21 10:33:36

标签: android android-recyclerview

我收到此错误"令牌上的语法错误,而是预期AnnotationName"。任何人都可以解决它.-- Android

mRecyclerView.setLayoutManager(new LinearLayoutManager(products.this){
                mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
                  @Override
                  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                      super.onScrolled(recyclerView, dx, dy);

                      totalItemCount = linearLayoutManager.getItemCount();
                      lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();

                      if (!isLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {

                        if(totalItemCount!=array1.size()-1){
                          if (mOnLoadMoreListener != null) {
                              mOnLoadMoreListener.onLoadMore();
                          }
                          isLoading = true;
                       }
                      }
                  }
              });
            }
            });

我在第2行得到错误,即   mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){

提前谢谢。

1 个答案:

答案 0 :(得分:0)

 mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()){
         // what ever you want to do here is only for LinearLayoutManager methods
    });

    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            // implement your scrolled code here
        }
    });