Like in ListView to remove the TextView after the Nth element CardView



  • Got a list built on. cardView♪ How can it be for each, for example, 20 records to be inserted view (sighs) textViewand the list went on.

    What implementation is possible? I haven't encountered it, but I can imagine that: ♪ layout Maquita file cardviewI'd like to finish my writing. cardview That's it. textView And make him invisible. And then, in an adaptation check, make it visible, depending on what it is now. item It's on the list.



  • Enough in the method. getItemViewType() The adapter shall, depending on the current position, indicate another type of component:

    private static final int VIEW_TYPE_CARDVIEW = 0;
    private static final int VIEW_TYPE_TEXTVIEW = 0;
    

    @Override
    public int getItemViewType(int position) {
    return position % 20 == 0 ? VIEW_TYPE_TEXTVIEW : VIEW_TYPE_CARDVIEW;
    }

    And depending on the current type of element in the method getView() Grants TextView or CardView




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2