Java Code Examples for android.widget.Adapter#getViewTypeCount()

The following examples show how to use android.widget.Adapter#getViewTypeCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeparatedListAdapter.java    From RoMote with Apache License 2.0 6 votes vote down vote up
public int getItemViewType(int position) {
    int type = 1;
    for(Object section : this.sections.keySet()) {
        Adapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if(position == 0) return TYPE_SECTION_HEADER;
        if(position < size) return type + adapter.getItemViewType(position - 1);

        // otherwise jump into next section
        position -= size;
        type += adapter.getViewTypeCount();
    }
    return -1;
}
 
Example 2
Source File: SeparatedListAdapter.java    From sensordatacollector with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getItemViewType(int position)
{
    int type = 1;
    for(String section : this.sections.keySet()) {
        Adapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if(position == 0)
            return TYPE_SECTION_HEADER;
        if(position < size)
            return type + adapter.getItemViewType(position - 1);

        // otherwise jump into next section
        position -= size;
        type += adapter.getViewTypeCount();
    }
    return -1;
}
 
Example 3
Source File: SeparatedListAdapter.java    From padland with Apache License 2.0 6 votes vote down vote up
public int getItemViewType(int position) {
    int type = 1;
    for(Object section : this.sections.keySet()) {
        Adapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if(position == 0) return TYPE_SECTION_HEADER;
        if(position < size) return type + adapter.getItemViewType(position - 1);

        // otherwise jump into next section
        position -= size;
        type += adapter.getViewTypeCount();
    }
    return -1;
}
 
Example 4
Source File: SeparatedListAdapter.java    From Makeblock-App-For-Android with MIT License 6 votes vote down vote up
@Override
public int getItemViewType(int position) {
    int type = 1;
    for (Object section : this.sections.keySet()) {
        Adapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;
        // check if position inside this section
        if (position == 0)
            return TYPE_SECTION_HEADER;
        if (position < size)
            return type + adapter.getItemViewType(position - 1);

        // otherwise jump into next section
        position -= size;
        type += adapter.getViewTypeCount();
    }
    return -1;
}
 
Example 5
Source File: SeparatedListAdapter.java    From BatteryFu with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getItemViewType(int position) {
    int type = 1;
    for (int i = 0; i < headers.getCount(); i++) {
        String section = headers.getItem(i);
        Adapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if (position == 0)
            return TYPE_SECTION_HEADER;
        if (position < size)
            return type + adapter.getItemViewType(position - 1);

        // otherwise jump into next section
        position -= size;
        type += adapter.getViewTypeCount();
    }
    return -1;
}
 
Example 6
Source File: SectionListAdapter.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
@Override
public int getItemViewType(int position)
{
    int type = 1;
    
    for (final Object section : sectionMap.keySet())
    {
        
        final Adapter adapter = sectionMap.get(section);
        final int size = adapter.getCount() + (hasSectionHeader ? 1 : 0);
        
        if (position == 0 && hasSectionHeader)
            return TYPE_SECTION_HEADER;
        
        if (position < size)
            return type + adapter.getItemViewType(position - 1);
        
        position -= size;
        type += adapter.getViewTypeCount();
    }
    
    return -1;
}
 
Example 7
Source File: SeparatedListAdapter.java    From RoMote with Apache License 2.0 5 votes vote down vote up
public int getViewTypeCount() {
    // assume that headers count as one, then total all sections
    int total = 1;
    for(Adapter adapter : this.sections.values())
        total += adapter.getViewTypeCount();
    return total;
}
 
Example 8
Source File: SeparatedListAdapter.java    From sensordatacollector with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getViewTypeCount()
{
    // assume that headers count as one, then total all sections
    int total = 1;
    for(Adapter adapter : this.sections.values())
        total += adapter.getViewTypeCount();
    return total;
}
 
Example 9
Source File: SeparatedListAdapter.java    From padland with Apache License 2.0 5 votes vote down vote up
public int getViewTypeCount() {
    // assume that headers count as one, then total all sections
    int total = 1;
    for(Adapter adapter : this.sections.values())
        total += adapter.getViewTypeCount();
    return total;
}
 
Example 10
Source File: SeparatedListAdapter.java    From Makeblock-App-For-Android with MIT License 5 votes vote down vote up
@Override
public int getViewTypeCount() {
    // assume that headers count as one, then total all sections
    int total = 1;
    for (Adapter adapter : this.sections.values())
        total += adapter.getViewTypeCount();
    return total;
}
 
Example 11
Source File: SeparatedListAdapter.java    From BatteryFu with GNU General Public License v2.0 5 votes vote down vote up
@Override
public int getViewTypeCount() {
    // assume that headers count as one, and that there will be at least a itemViewType.
    // then total all sections
    int total = 2;
    for (Adapter adapter : this.sections.values())
        total += adapter.getViewTypeCount();
    return total;
}
 
Example 12
Source File: SectionListAdapter.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
@Override
public int getViewTypeCount()
{
    int total = 1;
    
    for (final Adapter adapter : sectionMap.values())
        total += adapter.getViewTypeCount();
    
    return total;
}