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>
これらの文字列   ...
そして、どのように文字列
がアイコンになったの意味は何ですか?
資産/フォントにフォントファイル(MaterialDesignIcons.ttf)がありますか?
この方法の原則は何もわかりません。
この方法の原則は何もわかりません。
'&#xea08; &#xe937; &#xeac6; 'これらは単なる文字列です。それらの色を 'res'フォルダの' colors.xml'に移動して変更したい場合は、変更してください。 – Kathi
ご返信ありがとうございました 時計のアップデート:) –
あなたの更新のために私の答えをご覧ください – Kathi