当前位置: 首页>>代码示例>>Java>>正文


Java Adapter.getView方法代码示例

本文整理汇总了Java中android.widget.Adapter.getView方法的典型用法代码示例。如果您正苦于以下问题:Java Adapter.getView方法的具体用法?Java Adapter.getView怎么用?Java Adapter.getView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Adapter的用法示例。


在下文中一共展示了Adapter.getView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getView

import android.widget.Adapter; //导入方法依赖的package包/类
@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;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:25,代码来源:SectionListAdapter.java

示例2: getView

import android.widget.Adapter; //导入方法依赖的package包/类
@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;

        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;
}
 
开发者ID:Kamshak,项目名称:foursquared,代码行数:17,代码来源:SeparatedListAdapter.java

示例3: getView

import android.widget.Adapter; //导入方法依赖的package包/类
@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;
}
 
开发者ID:wseemann,项目名称:RoMote,代码行数:18,代码来源:SeparatedListAdapter.java

示例4: getWidestView

import android.widget.Adapter; //导入方法依赖的package包/类
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;
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-nui,代码行数:16,代码来源:ProofActivity.java

示例5: onActivityCreated

import android.widget.Adapter; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);


    if (getView() != null) {

        ListView listView = (ListView) getView().findViewById(android.R.id.list);
        Adapter adapter = listView.getAdapter();

        if (adapter != null) {
            int height = 0;
            //int height = listView.getPaddingTop() + listView.getPaddingBottom();

            for (int i = 0; i < adapter.getCount(); i++) {
                View item = adapter.getView(i, null, listView);

                item.measure(0, 0);
                height += item.getMeasuredHeight();
            }

            LinearLayout frame = (LinearLayout) getActivity().findViewById(R.id.preference_fragment); //Modify this for your fragment

            ViewGroup.LayoutParams param = frame.getLayoutParams();
            param.height = height + (listView.getDividerHeight() * adapter.getCount());
            frame.setLayoutParams(param);
        }
    }

}
 
开发者ID:gabm,项目名称:TapAndTurn,代码行数:31,代码来源:MainActivity.java

示例6: onItemSelected

import android.widget.Adapter; //导入方法依赖的package包/类
@Override
public void onItemSelected(AdapterView<?> parent, View v, int pos, long id)
{
	invoke(parent, v, pos, id);
	if (galleryListener != null)
	{
		galleryListener.onItemSelected(parent, v, pos, id);
	}
	if (galleryListen)
	{
		Integer selected = (Integer) parent.getTag(AQuery.TAG_NUM);
		if (selected != pos)
		{
			Adapter adapter = parent.getAdapter();
			parent.setTag(AQuery.TAG_NUM, pos);
			int count = parent.getChildCount();
			//AQUtility.debug("redrawing", count);
			int first = parent.getFirstVisiblePosition();
			for (int i = 0; i < count; i++)
			{
				View convertView = parent.getChildAt(i);
				int drawPos = first + i;
				Integer lastDrawn = (Integer) convertView.getTag(AQuery.TAG_NUM);
				if (lastDrawn != null && lastDrawn.intValue() == drawPos)
				{
					//AQUtility.debug("skip", drawPos);
				}
				else
				{
					//AQUtility.debug("redraw", drawPos);
					adapter.getView(drawPos, convertView, parent);
				}
			}
		}
	}
}
 
开发者ID:libit,项目名称:lr_dialer,代码行数:37,代码来源:Common.java


注:本文中的android.widget.Adapter.getView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。