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

The following examples show how to use android.widget.Adapter#getView() . 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
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    int sectionnum = 0;
    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 headers.getView(sectionnum, convertView, parent);
        if(position < size) return adapter.getView(position - 1, convertView, parent);

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;
}
 
Example 2
Source File: SeparatedListAdapter.java    From sensordatacollector with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    int sectionnum = 0;
    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 headers.getView(sectionnum, convertView, parent);
        if(position < size)
            return adapter.getView(position - 1, convertView, parent);

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;
}
 
Example 3
Source File: SeparatedListAdapter.java    From shortyz with GNU General Public License v3.0 6 votes vote down vote up
public View getView(int i, View view, ViewGroup group) {
    int sectionnum = 0;

    for (Adapter adapter : this.sections) {
        int size = adapter.getCount() + 1;

        // check if position inside this section
        if (i == 0) {
            return headers.getView(sectionnum, view, group);
        }

        if (i < size) {
            return adapter.getView(i - 1, view, group);
        }

        // otherwise jump into next section
        i -= size;
        sectionnum++;
    }

    return null;
}
 
Example 4
Source File: SeparatedListAdapter.java    From padland with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    int sectionnum = 0;
    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 headers.getView(sectionnum, convertView, parent);
        if(position < size) return adapter.getView(position - 1, convertView, parent);

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;
}
 
Example 5
Source File: SeparatedListAdapter.java    From Makeblock-App-For-Android with MIT License 6 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
    int sectionnum = 0;
    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 headers.getView(sectionnum, convertView, parent);
        if (position < size)
            return adapter.getView(position - 1, convertView, parent);

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;
}
 
Example 6
Source File: SeparatedListAdapter.java    From BatteryFu with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    int sectionnum = 0;
    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 headers.getView(sectionnum, convertView, parent);
        if (position < size)
            return adapter.getView(position - 1, convertView, parent);

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;
}
 
Example 7
Source File: SectionListAdapter.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, final View convertView, final ViewGroup parent)
{
    
    int sectionNum = 0;
    
    for (final String sectionName : sectionMap.keySet())
    {
        final Adapter adapter = sectionMap.get(sectionName);
        
        final int size = adapter.getCount() + (hasSectionHeader ? 1 : 0);
        
        if (position == 0 && hasSectionHeader)
            return sectionAdapter.getView(sectionNum, convertView, parent);
        
        if (position < size)
            return adapter.getView(position - 1, convertView, parent);
        
        position -= size;
        sectionNum++;
    }
    
    return null;
}
 
Example 8
Source File: ProofActivity.java    From Mupdf with Apache License 2.0 5 votes vote down vote up
private static int getWidestView(Context context, Adapter adapter)
{
	int maxWidth = 0;
	View view = null;
	FrameLayout fakeParent = new FrameLayout(context);
	for (int i=0, count=adapter.getCount(); i<count; i++) {
		view = adapter.getView(i, view, fakeParent);
		view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
		int width = view.getMeasuredWidth();
		if (width > maxWidth) {
			maxWidth = width;
		}
	}
	return maxWidth;
}