public RegionVH(View view) { super(new MaterialRippleLayout(view.getContext())); tv = new TextView(getContext()); tv.setLayoutParams( new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, JUtils.dip2px(48))); tv.setGravity(Gravity.CENTER); ((MaterialRippleLayout) itemView).addView(tv); ((MaterialRippleLayout) itemView) .setRippleColor(getContext().getResources().getColor(R.color.gray)); itemView.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, JUtils.dip2px(48))); }
@Override public View onCreateView(ViewGroup parent) { MaterialRippleLayout layout = new MaterialRippleLayout(getContext()); TextView tv = new TextView(parent.getContext()); tv.setLayoutParams( new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, JUtils.dip2px(48))); tv.setGravity(Gravity.CENTER); tv.setText(title); layout.addView(tv); layout.setRippleColor(getContext().getResources().getColor(R.color.gray)); layout.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, JUtils.dip2px(48))); return layout; }
private void initView() { setOrientation(HORIZONTAL); setBackgroundColor(Color.WHITE); province = new RecyclerView(getContext()); province.setLayoutParams(new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1)); province.setLayoutManager(new LinearLayoutManager(getContext())); province.setAdapter( (provinceAdapter = new RegionAdapter( getContext(), new RegionSelectCallback() { @Override public void selected(Region region) { cityAdapter.clear(); cityAdapter.addAll(RegionModel.getInstance().getCityList(region.getCid())); cityHeader.setRegion(region); regionAdapter.clear(); regionAdapter.addAll( RegionModel.getInstance().getRegionList(cityAdapter.getItem(0).getCid())); } }))); addView(province); View divider1 = new View(getContext()); divider1.setLayoutParams( new LayoutParams(JUtils.dip2px(0.3f), ViewGroup.LayoutParams.MATCH_PARENT)); divider1.setBackgroundColor(Color.GRAY); addView(divider1); city = new RecyclerView(getContext()); city.setLayoutParams(new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1)); city.setLayoutManager(new LinearLayoutManager(getContext())); city.setAdapter( (cityAdapter = new RegionAdapter( getContext(), new RegionSelectCallback() { @Override public void selected(Region region) { regionAdapter.clear(); regionAdapter.addAll(RegionModel.getInstance().getRegionList(region.getCid())); regionHeader.setRegion(region); } }))); addView(city); View divider2 = new View(getContext()); divider2.setLayoutParams( new LayoutParams(JUtils.dip2px(0.3f), ViewGroup.LayoutParams.MATCH_PARENT)); divider2.setBackgroundColor(Color.GRAY); addView(divider2); region = new RecyclerView(getContext()); region.setLayoutParams(new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1)); region.setLayoutManager(new LinearLayoutManager(getContext())); region.setAdapter( (regionAdapter = new RegionAdapter( getContext(), new RegionSelectCallback() { @Override public void selected(Region region) { callback.selected(region); } }))); addView(region); }