There is an adapter:
public class AdapterInfoContact extends RecyclerView.Adapter<RecyclerView.ViewHolder> { List<CountryCallingCode> valueContact = new ArrayList<>(); Context context; RecyclerItemClick itemClick; public AdapterInfoContact(Context context, List<CountryCallingCode> features) { this.valueContact = features; this.context = context; } @Override public int getItemViewType(int position) { return 0; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { RecyclerView.ViewHolder viewHolder = null; LayoutInflater inflater = LayoutInflater.from(parent.getContext()); switch (viewType) { case 0: View item_Header = inflater.inflate(R.layout.item_filter, parent, false); viewHolder = new ValHolder(item_Header); break; } return viewHolder; } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: ValHolder commentHolder = (ValHolder) holder; configureHeaderView(commentHolder, position); break; } } private void configureHeaderView(ValHolder valueHolder, int position) { if (valueContact.get(position).getInfo() != null) { if (position == 0) { valueHolder.mTvTitle.setText(valueContact.get(position).getInfo().getLogin()); } else if (position == valueContact.size() - 1) { try { if (valueContact.get(position).getInfo().getLocationCountry() != null && valueContact.get(position).getInfo().getLocationCountry().getValue() != null) valueHolder.mTvTitle.setText(valueContact.get(position).getInfo().getLocationCountry().getValue() + "," + valueContact.get(position).getInfo().getLocationRegion().getValue()); } catch (Exception e) { valueHolder.mTvTitle.setText(context.getString(R.string.country_tag)); } } } else { valueHolder.mTvTitle.setText("(" + valueContact.get(position).getCountryCode() + ") " + valueContact.get(position).getNationalNumber()); } } @Override public int getItemCount() { return valueContact.size(); } class ValHolder extends RecyclerView.ViewHolder implements View.OnClickListener { @BindView(R.id.title_filter) TextView mTvTitle; public ValHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); itemView.setOnClickListener(this); } @Override public void onClick(View v) { if (getAdapterPosition() == 0) { itemClick.itemLogin(valueContact.get(0).getInfo(), v); } else if (getAdapterPosition() == valueContact.size() - 1) { itemClick.itemMap(valueContact.get(getAdapterPosition()).getInfo(), v); } else { itemClick.itemContact(valueContact.get(getAdapterPosition()), v); } } } public interface RecyclerItemClick { void itemContact(CountryCallingCode code, View view); void itemLogin(Ad info, View view); void itemMap(Ad info, View view); } public void SetOnItemClickListener(final RecyclerItemClick mItemClickListener) { this.itemClick = mItemClickListener; } } I would like to place the pictures in such a way as to get a list, BUT already with pictures). Please tell me how it can be done more painlessly.
item_filter Code:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/title_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/_10sdp" android:maxLines="1" /> <TextView android:id="@+id/value_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLines="1" android:layout_alignParentRight="true" android:gravity="right" android:layout_marginRight="@dimen/_10sdp" android:layout_marginTop="@dimen/_10sdp" android:layout_marginBottom="@dimen/_10sdp" android:layout_toRightOf="@+id/title_filter" android:layout_toEndOf="@+id/title_filter" /> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="0.5dp" android:background="@color/new_divider" /> </LinearLayout>
В котором как Вы уже наверное успели заметить есть два RecyclerView.- What is it like? - post_zeew