addOnScrollListener içinde ne yapmak istediğimi yazdım. public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { RecyclerView recyclerView; private boolean loading = true; int pastVisiblesItems, visibleItemCount, totalItemCount;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    String urlhead="https://gelecegiyazanlar.turkcell.com.tr/gypservis/article/retrieve?nitems=10&index=";
    final int urlbody=0;
    String urltail="&kategoriID=718";

    recyclerView = (RecyclerView)findViewById(R.id.recyclerview);
    final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this);
    recyclerView.setLayoutManager(linearLayoutManager);

    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (dy > 0) //check for scroll down
            {
                visibleItemCount = linearLayoutManager.getChildCount();
                totalItemCount = linearLayoutManager.getItemCount();
                pastVisiblesItems = linearLayoutManager.findFirstVisibleItemPosition();

                if (loading) {
                    if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
                        loading = false;
                       Toast.makeText(MainActivity.this,"last item",Toast.LENGTH_SHORT).show();
                        //burada urlbodyi 1 arttrıp yeni gelen elemanların recyclerviewa eklenmesini istiyorum
                    }
                }
            }
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    StringRequest myReq = new StringRequest(Request.Method.GET,urlhead+urlbody+urltail, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            GsonBuilder gsonb = new GsonBuilder();
            Gson gson = new Gson();
            Type listType = new TypeToken<List<Post>>(){}.getType();
            List<Post> posts = (List<Post>) gson.fromJson(response, listType);

            final RecyclerViewAdapter adapter = new RecyclerViewAdapter(posts);
            recyclerView.setAdapter(adapter);

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {

            // Server'a bağlanırken yada veri çekilirken hata oldu
            System.out.println(error.getMessage());
        }
    }) {
    };

    AppController.getInstance().addToRequestQueue(myReq);

}

soruldu: 14 Mar, 12:25

serhatcoskun's gravatar image

serhatcoskun
10223
cevap kabul oranı: 0%

değiştirildi: 15 Mar, 08:47

ersinyildiz's gravatar image

ersinyildiz
2.8k31438

Bu soruya ilk cevap veren sen ol!
toggle preview

Bu soruyu takip et

E-Posta üzerinden:

Üyelik girişi yaptıktan sonra abonelik işlemlerini yapabilirsiniz

RSS üzerinden:

Cevaplar

Cevaplar ve Yorumlar

Yazı Formatlama

  • *italic* ya da _italic_
  • **bold** ya da __bold__
  • link:[text](http://url.com/ "başlık")
  • resim?![alt text](/path/img.jpg "başlık")
  • liste: 1. Foo 2. Bar
  • temel HTML etiketleri de kullanılabilir

Bu sorunun etiketleri:

×819
×5
×2
×1

Soruldu: 14 Mar, 12:25

Görüntüleme: 196 kez

Son güncelleme: 15 Mar, 08:47

powered by BitNami OSQA