package com.chad.baserecyclerviewadapterhelper.adapter; import android.text.TextPaint; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.view.View; import android.widget.TextView; import com.chad.baserecyclerviewadapterhelper.R; import com.chad.baserecyclerviewadapterhelper.data.DataServer; import com.chad.baserecyclerviewadapterhelper.entity.Status; import com.chad.baserecyclerviewadapterhelper.util.SpannableStringUtils; import com.chad.baserecyclerviewadapterhelper.util.ToastUtils; import com.chad.baserecyclerviewadapterhelper.util.Utils; import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseViewHolder; /** * 文 件 名: AnimationAdapter * 创 建 人: Allen * 创建日期: 16/12/24 15:33 * 邮 箱: AllenCoder@126.com * 修改时间: * 修改备注: */ public class NestAdapter extends BaseQuickAdapter<Status, BaseViewHolder> { public NestAdapter() { super( R.layout.layout_nest_item, DataServer.getSampleData(20)); } @Override protected void convert(BaseViewHolder helper, Status item) { helper.addOnClickListener(R.id.tweetText); switch (helper.getLayoutPosition()% 3){ case 0: helper.setImageResource(R.id.img,R.mipmap.animation_img1); break; case 1: helper.setImageResource(R.id.img,R.mipmap.animation_img2); break; case 2: helper.setImageResource(R.id.img,R.mipmap.animation_img3); break; } helper.setText(R.id.tweetName,"Hoteis in Rio de Janeiro"); String msg="\"He was one of Australia's most of distinguished artistes, renowned for his portraits\""; ( (TextView)helper.getView(R.id.tweetText)).setText(SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create()); ( (TextView)helper.getView(R.id.tweetText)).setMovementMethod(LinkMovementMethod.getInstance()); } ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View widget) { ToastUtils.showShortToast("事件触发了 landscapes and nedes"); } @Override public void updateDrawState(TextPaint ds) { ds.setColor(Utils.getContext().getResources().getColor(R.color.clickspan_color)); ds.setUnderlineText(true); } }; }