0

StaggeredGridLayoutManagerを使用して2つの列でRecyclerViewを作成しました。すべての項目に2つの画像とテキストが含まれています。最初の画像のサイズは284 * 572,840 * 401または283 * 232 )2番目の35 * 35とテキスト、リストがすばらしく見えるが、問題はスクロールがスムーズで連続的ではなく、ユーザーがスクロールしたときに画像がローカルストレージ(ドロアブル)から取得していることスクロールの経験を承認する。あなたは、パフォーマンスを向上させるためにあなたのイメージをキャッシュできるフラグメントStaggeredGridLayoutを使用してAndroid RecyclerViewでスクロールがスムーズでない

RecyclerView myRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view); 

StaggeredGridLayoutManager setLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); 
FantasyTabAdapter fantasyTabAdapter = new FantasyTabAdapter(getActivity(),fantasies); 

myRecyclerView.setLayoutManager(setLayoutManager); 
myRecyclerView.setAdapter(fantasyTabAdapter); 
+0

ファンタジーファンタジー映画についての情報を含むオブジェクトで使用することができます

this.fantasyImage.setImageResource(fantasy.getFantasyHeaderImageID()); 

:NTのキャッシング戦略は、そう、あなたが必要とするすべては、それらのいずれかをインポートしてのではなく、例えば、それを使用していますイメージとテキストのIDを取得する – user1684140

答えて

2

でRecyclerViewを設定FantasyTabAdpter.java

public class FantasyTabAdapter extends RecyclerView.Adapter<FantasyTabAdapter.MyViewHolder> { 
    private LayoutInflater inflater; 
    private ArrayList<Fantasy> fantasies; 

    public FantasyTabAdapter(Context context, ArrayList<Fantasy> fantasies) { 
     inflater = LayoutInflater.from(context); 
     this.fantasies = fantasies; 
    } 

    @Override 
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
     View view = inflater.inflate(R.layout.fantasy_tab_item, parent, false); 
     MyViewHolder holder = new MyViewHolder(view); 
     return holder; 
    } 

    @Override 
    public void onBindViewHolder(final MyViewHolder holder, int position) { 
     final Fantasy fantasy = fantasies.get(position); 
     holder.setData(fantasy, position); 
    } 

    @Override 
    public int getItemCount() { 
     return fantasies.size(); 
    } 

    class MyViewHolder extends RecyclerView.ViewHolder{ 
     ImageView fantasyImage; 
     TextView fantasyTitle; 
     ImageView fantasyStatus; 

     public MyViewHolder(View itemView) { 
      super(itemView); 
      fantasyImage = (ImageView) itemView.findViewById(R.id.fantasy_tab_image); 
      fantasyTitle = (TextView) itemView.findViewById(R.id.fantasy_tab_title); 
      fantasyStatus = (ImageView) itemView.findViewById(R.id.fantasy_tab_status); 
     } 

     public void setData(Fantasy fantasy, int position) { 
      this.fantasyTitle.setText(fantasy.getFantasyHeader()); 
      this.fantasyImage.setImageResource(fantasy.getFantasyHeaderImageID()); 
      this.fantasyStatus.setImageDrawable(fantasy.statusImagePlsgod); 
     } 
    } 
} 

Glide

picasso:そしてその理由とそれを解決する方法についてのアイデアを理解したあなたのようなイメージライブラリを使用することができます

Caching UI data

The Magic of LRU Cache

:最初のこれらの2本のビデオを見ます

たものimpleme我々はそこから、あなたは

Picasso.with(context).load(fantasy.getFantasyHeaderImageID()).into(this.fantasyImage); 
+1

グライドははるかに優れています –

関連する問題