title: How to sort recyclerView right
body: <p>I created a <code>recyclerView</code>(see in this image) <a href="https://i.stack.imgur.com/TIb9h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TIb9h.png" alt="enter image description here"></a></p>
  
  <p>But I'm not getting result that I want. I need get this:</p>
  
  <p><a href="https://i.stack.imgur.com/AUxBy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AUxBy.png" alt="enter image description here"></a></p>
  
  <p>You see I already grouped the profession, and all professions has it's own icon. So I'll now include my <code>recyclerView</code> code. How can I do like in image? If I've done something wrong, please tell me, not give downvote.</p>
  
  <p>Here's the items class.</p>
  
  <pre><code>public class Rec_Items {
  
      private int image;
      private String fullName;
      private String profession;
  
      public Rec_Items(int image, String fullName, String profession) {
          this.image = image;
          this.fullName = fullName;
          this.profession = profession;
      }
  
      public int getImage() {
          return image;
      }
  
      public String getFullName() {
          return fullName;
      }
  
      public String getProfession() {
          return profession;
      }
  }
  </code></pre>
  
  <p>Now here the <code>adapter</code> with it's <code>ViewHolder</code>.</p>
  
  <pre><code>public class SupportersAdapter extends RecyclerView.Adapter&lt;SupportersAdapter.MyViewHolder&gt; {
  
      Context context;
      List&lt;Supporters_item&gt; list = new ArrayList&lt;&gt;();
  
      public SupportersAdapter(Context context, List&lt;Supporters_item&gt; list) {
          this.context = context;
          this.list = list;
      }
  
  
      @Override
      public SupportersAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v;
          v = LayoutInflater.from(context).inflate(R.layout.supporters_view_item, parent, false);
          MyViewHolder holder = new MyViewHolder(v);
          return holder;
      }
  
      @Override
      public void onBindViewHolder(SupportersAdapter.MyViewHolder holder, int position) {
          holder.imageView.setImageResource(list.get(position).getImage());
          holder.fullName.setText(list.get(position).getFullName());
          holder.profession.setText(list.get(position).getProfession());
  
          if (list.get(position).getProfession().equals("Actress")) {
              holder.icon.setImageResource(R.drawable.medical);
          }
          if (list.get(position).getProfession().equals("Builder")) {
              holder.icon.setImageResource(R.drawable.builderkey);
          }
          if (list.get(position).getProfession().equals("Designer")) {
              holder.icon.setImageResource(R.drawable.shopping);
          }
          if (list.get(position).getProfession().equals("Programmer")) {
              holder.icon.setImageResource(R.drawable.education);
          }
  
          if (position &gt; 0) {
              if (!list.get(position).getProfession().substring(0,1).equals(list.get(position-1).getProfession().substring(0, 1))) {
                  holder.view.setVisibility(View.VISIBLE);
                  holder.icon.setVisibility(View.VISIBLE);
              }
          }
  
      }
  
      @Override
      public int getItemCount() {
          return list.size();
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder {
  
          ImageView imageView, icon;
          TextView fullName, profession;
          View view;
  
          public MyViewHolder(View itemView) {
              super(itemView);
  
              imageView = (ImageView) itemView.findViewById(R.id.support_picture);
              fullName = (TextView) itemView.findViewById(R.id.fName);
              profession = (TextView) itemView.findViewById(R.id.profession);
              icon = (ImageView) itemView.findViewById(R.id.icon);
              view = itemView.findViewById(R.id.bottomLine);
  
          }
      }
  }
  </code></pre>
  
  <p>I've done the group part in <code>onBindViewHolder()</code>, so watch there, I'm getting not the result that I want, I want to get the image result.</p>
  
  <p>Here's the <code>MainActivity</code> class.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private List&lt;Rec_Items&gt; list;
      private RecyclerView recyclerView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          recyclerView = (RecyclerView) findViewById(R.id.supporters_recycler);
          add();
          Adapter adapter = new Adapter(this, list);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
          recyclerView.setAdapter(adapter);
  
      }
  
      public void add(){
          list = new ArrayList&lt;&gt;();
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Actress"));
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Programmer"));
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Builder"));
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Designer"));
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Actress"));
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Programmer"));
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Builder"));
          list.add(new Rec_Items(R.drawable.pfl_img, "Name Surname", "Designer"));
      }
  }
  </code></pre>
  
  <p>How can I modify my code, what to change for getting grouped <code>recyclerView</code>?</p>