-1

当我从 Json 获取数据并放入 recyclerview 时。它滚动得很慢?请帮我解决这个问题。

recyclerView = findViewById(R.id.recycleview);
            adapter1 = new Landing_recycler_adapter(MainActivity.this, movieList);
            GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(),2);
            gridLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); // set Horizontal Orientation
            recyclerView.setLayoutManager(gridLayoutManager); // set LayoutManager to RecyclerView
    //        recyclerView.setLayoutManager(new GridLayoutManager(this, GridLayoutManager.HORIZONTAL, true));


            recyclerView.setHasFixedSize(true);
            recyclerView.setAdapter(adapter1);

            getJsonData();
4

2 回答 2

0

用这个

            getJsonData();
            recyclerView = findViewById(R.id.recycleview);
            adapter1 = new Landing_recycler_adapter(MainActivity.this, movieList);

            recyclerView.setLayoutManager(new LinearLayoutManager(this));
            recyclerView.setAdapter(adapter1);

或者

            getJsonData();
            recyclerView = findViewById(R.id.recycleview);
            adapter1 = new Landing_recycler_adapter(MainActivity.this, movieList);

            recyclerView.setLayoutManager(new GridLayoutManager(this,2));
            recyclerView.setAdapter(adapter1);

于 2019-10-31T11:06:38.280 回答
0

并且还禁用 RecyclerView 的嵌套滚动

recyclerView.setNestedScrollingEnabled(false);
于 2019-10-31T11:31:49.747 回答