public class DrawerAdapter extends BaseAdapter {
private List<DrawerItemModel> mDrawerItems;
private LayoutInflater mInflater;
public DrawerAdapter(Context context) {
mInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mDrawerItems = getTravelDummyList();
}
@Override
public int getCount() {
return mDrawerItems.size();
}
@Override
public Object getItem(int position) {
return mDrawerItems.get(position);
}
@Override
public long getItemId(int position) {
return mDrawerItems.get(position).getId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(
R.layout.list_view_item_navigation_drawer_travel, parent,
false);
holder = new ViewHolder();
holder.dividerTop = (View) convertView
.findViewById(R.id.divider_top);
holder.icon = (TextView) convertView.findViewById(R.id.icon);
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.dividerBottom = (View) convertView.findViewById(R.id.divider_bottom);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
DrawerItemModel item = mDrawerItems.get(position);
holder.icon.setText(item.getIconRes());
holder.title.setText(item.getText());
if (position != 0)
holder.dividerTop.setVisibility(View.GONE);
return convertView;
}
public static ArrayList<DrawerItemModel> getTravelDummyList() {
ArrayList<DrawerItemModel> list = new ArrayList<>();
list.add(new DrawerItemModel(0,0, "Monuments", R.string.app_name));
list.add(new DrawerItemModel(1,00, "Hotels", R.string.material_icon_sleep));
list.add(new DrawerItemModel(2, 1, "Restaurants", R.string.material_icon_eat));
list.add(new DrawerItemModel(3, 2, "Sport et Loisirs", R.string.material_icon_play));
list.add(new DrawerItemModel(4, 3, "Shopping", R.string.material_icon_shop));
list.add(new DrawerItemModel(5, 4, "Méteo", R.string.material_icon_star));
list.add(new DrawerItemModel(6, 5, "Notes", R.string.material_icon_message));
list.add(new DrawerItemModel(6, 5, "Photos et Videos", R.string.material_icon_video));
list.add(new DrawerItemModel(7, 6, "Circuit Touristique", R.string.fontello_search));
list.add(new DrawerItemModel(7, 6, "Recherche", R.string.material_icon_image_box));
return list;
}
private static class ViewHolder {
public TextView icon;
public/* Roboto */TextView title;
public View dividerTop;
public View dividerBottom;
}
}
String.xml
<!-- Material Design Icons -->
<string name="material_icon_bike"></string>
<string name="material_icon_go"></string>
<string name="material_icon_sleep"></string>
<string name="material_icon_eat"></string>
<string name="material_icon_play"></string>
<string name="material_icon_drink"></string>
<string name="material_icon_party"></string>
这些字符串   ...
的含义是什么
字符串
如何成为图标?
我在assets / font ??
中有一个字体文件(MaterialDesignIcons.ttf)我不知道这种方法的原理是什么?
我不知道这种方法的原理是什么?
答案 0 :(得分:2)
字符串

如何成为图标?
字符串可以成为图标,(:))它的字符串编码技术,这里是HTML实体(十六进制)编码。有很多编码技术。
当您在智能手机中键入:)
然后成为笑脸表情符号时,请说明编码也起作用。
我在assets / font ??
中有一个字体文件(MaterialDesignIcons.ttf)
如果我理解正确,你问的是将.ttf文件放在font文件夹中吗?
这个.ttf与这些图标没有任何关系。
我不知道这种方法的原理是什么?
希望您通过查看Unique Characters list
列表来了解原则注意:如果您打算更改这些图标的颜色,则需要找出它们的字符串值