RecyclerView中每行的返回高度

时间:2016-04-02 15:07:17

标签: java android android-recyclerview adapter

如何在RecycleView中返回每行的高度?我需要它在RecycleView中的滚动条高度,如iOS中的heightForRowAtIndexPath。 我对RecyclerView.Adapter提供了以下RecyclerView

class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {

private String[] items = {"My items"};


public static class ViewHolder extends RecyclerView.ViewHolder {

    public View mTextView;
    public ViewHolder(View v) {
        super(v);
        mTextView = v;
    }
}

public MyAdapter(String[] myDataset) {
    //items = myDataset;
}

@Override
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_view_text_item, parent, false);
    ViewHolder vh = new ViewHolder(v);
    return vh;
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    ((TextView)holder.mTextView.findViewById(R.id.textItemTextView)).setText(items[position]);
}

@Override
public int getItemCount() {
    return items.length;
}
}

但是行具有不同的高度,并且在滚动期间滚动更改。

1 个答案:

答案 0 :(得分:0)

您可以使用以下内容:

test._dummy_indexes_2p23