我想在我的RecyclerView中添加Fast-Scroll-Feature(如在Android联系人应用程序或Whatsapp联系人中)?
我也会使用列表视图,但我的应用程序需要Cards
在同一版面上!
如果实施快速滚动到Recyclerview太难了,使用ViewStub也是一种选择吗?
我的RecyclerViewAdapter:
public class SongRecyclerViewAdapter extends RecyclerView.Adapter<SongRecyclerViewAdapter.Holder> {
private Song[] sSongs;
public SongRecyclerViewAdapter(Song[] songs) {
sSongs = songs;
}
@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_songview, parent, false);
Holder holder = new Holder(view);
return holder;
}
@Override
public void onBindViewHolder(Holder holder, int position) {
//holder.imvSong.setImageResource(R.drawable.standardartwork);
holder.txvSongTitle.setText(sSongs[position].getTitle());
holder.txvSongInfo.setText(sSongs[position].getArtists());
}
@Override
public int getItemCount() {
return sSongs != null ? sSongs.length : 0;
}
public class Holder extends RecyclerView.ViewHolder {
LinearLayout linearLayout;
ImageView imvSong;
TextView txvSongTitle;
TextView txvSongInfo;
public Holder(View layout) {
super(layout);
linearLayout = (LinearLayout) layout;
imvSong = (ImageView) layout.findViewById(R.id.imvSong);
txvSongTitle = (TextView) layout.findViewById(R.id.adap_txvSongtitle);
txvSongInfo = (TextView) layout.findViewById(R.id.txvSongInfo);
}
}
}
谢谢!
答案 0 :(得分:0)
代码中的问题是注释行:
join
要解决这个问题,你有2个解决方案:
1)如果你有少量的已知图像,你可以在初始化时创建一次位图/绘图,然后你只需要引用它们。
2)创建位图缓存,智能方式解码位图以及可重复使用的位图池和池化机制。这不是微不足道的,这就是第三方图书馆为您所做的。我不建议你自己实施它。