class KeyAdpter extends TagAdapter<String>{ public KeyAdpter(List<String> datas) { super(datas); } @Override public View getView(FlowLayout parent, int position, String s) { TextView textView = new TextView(parent.getContext()); textView.setText(s); textView.setTextSize(15); return textView; } }
List<String> strings = new ArrayList<>(); strings.add("电动牙刷"); strings.add("豆豆鞋"); strings.add("沐浴露"); strings.add("榴莲"); strings.add("尤妮佳"); strings.add("雅诗兰黛"); strings.add("日东红茶"); strings.add("呵呵"); KeyAdpter adpter = new KeyAdpter(strings); flowLayout.setAdapter(adpter);