Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

求教在结合BaseRecyclerViewAdapterHelper实现粘性没效果 #31

Open
DuoLa512 opened this issue Oct 11, 2017 · 2 comments
Open

求教在结合BaseRecyclerViewAdapterHelper实现粘性没效果 #31

DuoLa512 opened this issue Oct 11, 2017 · 2 comments

Comments

@DuoLa512
Copy link

DuoLa512 commented Oct 11, 2017

主要代码:

在fragment中:
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mHeaderItemDecoration = new

PinnedHeaderItemDecoration.Builder(IncomeAdapter.TYPE_STICKY_HEAD)
.disableHeaderClick(false).create();

mRecyclerView.addItemDecoration(mHeaderItemDecoration);

mAdapter = new IncomeAdapter(R.layout.item_income, R.layout.lv_pointrecord_header, mList);

mAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);

mRecyclerView.setAdapter(mAdapter);

在Adapter中:
public class IncomeAdapter extends BaseSectionQuickAdapter<IncomeSection,BaseViewHolder> {

// public final static int TYPE_DATA = 1;
public static int TYPE_STICKY_HEAD = 1;
// public final static int TYPE_SMALL_STICKY_HEAD_WITH_DATA = 3;

public IncomeAdapter(int layoutResId, int sectionHeadResId, List data){
    super(layoutResId, sectionHeadResId, data);
}

@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    FullSpanUtil.onAttachedToRecyclerView(recyclerView, this, TYPE_STICKY_HEAD);
}

@Override
public void onViewAttachedToWindow(BaseViewHolder holder) {
    super.onViewAttachedToWindow(holder);
    FullSpanUtil.onViewAttachedToWindow(holder, this,TYPE_STICKY_HEAD );
}

@Override
protected void convertHead(BaseViewHolder helper, IncomeSection item) {
    helper.setText(R.id.lv_pointrecord_date,item.header);
}

@Override
protected void convert(BaseViewHolder helper, IncomeSection item) {

    Income income = item.t;
    helper.setText(R.id.tv_Week, TimeUtils.dateToWeek(income.getIncome_time()));
    helper.setText(R.id.tv_Time, income.getIncome_time());
    helper.setText(R.id.tv_Income_desc, income.getIncome_desc());
    helper.setText(R.id.tv_Income_money, "¥"+income.getIncome_monery()+"元");

}

实体类:
public class IncomeSection extends SectionEntity {

private List<Income> items;

// public static final int TYPE_HEADER = 1;
// public static final int TYPE_DATA = 2;

public IncomeSection(boolean isHeader, String header) {
    super(isHeader, header);
    items = new ArrayList<>();
}

public IncomeSection(Income income) {
    super(income);
    items = new ArrayList<>();
}

public void addIncome(Income item) {
    this.items.add(item);
}

public List<Income> getItems() {
    return items;
}

}

求教大佬,谢谢

@oubowu
Copy link
Owner

oubowu commented Oct 16, 2017

额 你要是能抽出给个demo我 我好定位问题啊orz

@KevinLium
Copy link

他没定义多布局的IncomeAdapter.TYPE_STICKY_HEAD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants