本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
}
}