/** * 作者:水东流 编于 2019/3/20 * 协助adapter中使用databing */ public class MyBaseViewHolder extends BaseViewHolder { public MyBaseViewHolder(View view) { super(view); } }
/** * 作者:水东流 编于 2019/3/20 * 关注适配器 */ public class FollowAdapter extends BaseQuickAdapter<XinHuaBean, MyBaseViewHolder> { public FollowAdapter(@Nullable List<XinHuaBean> data) { super(data); } @Override protected MyBaseViewHolder onCreateDefViewHolder(ViewGroup parent, int viewType) { ItemXinHuaFollowBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.item_xin_hua_follow, parent, false); return new MyBaseViewHolder(binding.getRoot()); } @Override protected void convert(MyBaseViewHolder helper, XinHuaBean item) { ItemXinHuaFollowBinding binding = DataBindingUtil.getBinding(helper.itemView); ImageLoaderUtil.getInstance().loadImage(mContext, item.getXinhuaCover(), helper.getView(R.id.cover)); binding.setXinhuabean(item); } }
item_xin_hua_follow 布局
<?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android"> <data> <variable name="xinhuabean" type="com.broken.molaware.xinhua_android.bean.home.XinHuaBean" /> </data> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/dp_16" android:gravity="center_vertical"> <ImageView android:id="@+id/cover" android:layout_width="35dp" android:layout_height="35dp" /> <LinearLayout android:layout_width="@dimen/dp_190" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_50" android:orientation="vertical"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{xinhuabean.xinHuaName}" android:textColor="@color/title" android:textSize="@dimen/text_size_17" /> <TextView android:id="@+id/little_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_5" android:ellipsize="end" android:text="@{xinhuabean.xinhuaDesc}" android:textColor="@color/little_title" android:textSize="@dimen/text_size_12" /> </LinearLayout> </FrameLayout> </layout>
followAdapter.isFirstOnly(false); //慢慢淡进 //adapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN); //慢慢放大进入 //adapter.openLoadAnimation(BaseQuickAdapter.SCALEIN); //从下滑入 // followAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM); //从左滑入 followAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT); //从有滑入 //adapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);