recyclerViewFavorable.setVisibility(View.VISIBLE);
//流布局展示
List<Map<String,Object>> ruleList = new ArrayList<>();
Map tempMap = null;
for (int i = 0;i<favorableList.length;i++){
tempMap = new HashMap();
tempMap.put("name",favorableList[i]);
ruleList.add(tempMap);
}
//设置主轴方向为横轴
FlexboxLayoutManager manager = new FlexboxLayoutManager(this, FlexDirection.ROW);
//设置item沿主轴方向的位置
manager.setJustifyContent(JustifyContent.FLEX_START);
//设置item 沿次轴方向的位置
manager.setAlignItems(AlignItems.CENTER);
recyclerViewFavorable.setLayoutManager(manager);
FavorableRecyclerAdapter favorableRecyclerAdapter =
new FavorableRecyclerAdapter(R.layout.item_favorable_fullmeet_1,ruleList,false);
recyclerViewFavorable.setAdapter(favorableRecyclerAdapter);
favorableAdapter.notifyDataSetChanged();
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewFavorable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:visibility="visible"
/>
/**
*优惠信息适配器
*/
public class FavorableRecyclerAdapter extends BaseQuickAdapter<Map<String,Object>, BaseViewHolder> {
/**
* 是否是商户列表页面 默认false
*/
private boolean isMerchantList;
public FavorableRecyclerAdapter(int layoutResId, @Nullable List<Map<String,Object>> data,boolean isMerchantList) {
super(layoutResId, data);
this.isMerchantList = isMerchantList;
}
@Override
protected void convert(BaseViewHolder baseViewHolder, Map<String,Object> objectMap) {
TextView tvFavorable = baseViewHolder.getView(R.id.tvFavorable);
if(isMerchantList){
tvFavorable.setTextSize(11);
//商户列表的本行商户优惠信息展示
// if (myList != null && myList.size() > 0) {
// Map<String,Object> map = myList.get(position);
tvFavorable.setText(JsonUtils.getString(objectMap.get("meetMoney"))+"减"+JsonUtils.getString(objectMap.get("reductionMoney")));
// }
}else {
// if (list != null && list.length > 0) {
//详情大小12
tvFavorable.setTextSize(12);
tvFavorable.setBackgroundResource(R.drawable.shape_stroke_red_favorable_detail);//替换边框
String favorable = JsonUtils.getString(JsonUtils.getString(objectMap.get("name")));
tvFavorable.setText(favorable.replace("-", "减"));
// }
}
}
}