Search in sources :

Example 1 with ListAdapter

use of de.westnordost.streetcomplete.view.ListAdapter in project StreetComplete by westnordost.

the class AddCyclewayForm method createAdapter.

private ListAdapter<Cycleway> createAdapter(List<Cycleway> items, final OnCyclewaySelected callback) {
    return new ListAdapter<Cycleway>(items) {

        @Override
        public ViewHolder<Cycleway> onCreateViewHolder(ViewGroup parent, int viewType) {
            return new ViewHolder<Cycleway>(LayoutInflater.from(parent.getContext()).inflate(R.layout.labeled_icon_button_cell, parent, false)) {

                @Override
                protected void onBind(final Cycleway item) {
                    ImageView iconView = itemView.findViewById(R.id.imageView);
                    TextView textView = itemView.findViewById(R.id.textView);
                    iconView.setImageResource(item.getIconResId(isLeftHandTraffic()));
                    textView.setText(item.nameResId);
                    itemView.setOnClickListener(view -> callback.onCyclewaySelected(item));
                }
            };
        }
    };
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ListAdapter(de.westnordost.streetcomplete.view.ListAdapter)

Aggregations

ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ListAdapter (de.westnordost.streetcomplete.view.ListAdapter)1