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


Java SpinnerAdapter.getView方法代码示例

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


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

示例1: onMeasure

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    SpinnerAdapter adapter = getAdapter();
    if (adapter != null && MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST) {
        View view = adapter.getView(getSelectedItemPosition(), null, this);
        if (view.getLayoutParams() == null)
            view.setLayoutParams(mDefaultLayoutParams);
        view.measure(widthMeasureSpec, heightMeasureSpec);
        int width = view.getMeasuredWidth();
        if (getBackground() != null) {
            getBackground().getPadding(mTempRect);
            width += mTempRect.left + mTempRect.right;
        }

        this.setMeasuredDimension(Math.min(width, MeasureSpec.getSize(widthMeasureSpec)), this.getMeasuredHeight());
    }

}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:19,代码来源:AutoResizeSpinner.java

示例2: compatMeasureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
private int compatMeasureContentWidth(SpinnerAdapter adapter, Drawable background) {
    if (adapter == null) {
        return 0;
    }
    int width = 0;
    View itemView = null;
    int itemType = 0;
    int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
    int start = Math.max(0, getSelectedItemPosition());
    int end = Math.min(adapter.getCount(), start + 15);
    for (int i = Math.max(0, start - (15 - (end - start))); i < end; i++) {
        int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        itemView = adapter.getView(i, itemView, this);
        if (itemView.getLayoutParams() == null) {
            itemView.setLayoutParams(new LayoutParams(-2, -2));
        }
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        width = Math.max(width, itemView.getMeasuredWidth());
    }
    if (background == null) {
        return width;
    }
    background.getPadding(this.mTempRect);
    return width + (this.mTempRect.left + this.mTempRect.right);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:31,代码来源:AppCompatSpinner.java

示例3: measureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
private int measureContentWidth(SpinnerAdapter adapter, Drawable background) {
if (adapter == null)
          return 0;	        

      int width = 0;
      View itemView = null;
      int itemType = 0;
      
      final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
      final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

      // Make sure the number of items we'll measure is capped. If it's a huge data set
      // with wildly varying sizes, oh well.
      int start = Math.max(0, getSelectedItemPosition());
      final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
      final int count = end - start;
      start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
      for (int i = start; i < end; i++) {
          final int positionType = adapter.getItemViewType(i);
          if (positionType != itemType) {
              itemType = positionType;
              itemView = null;
          }
          itemView = adapter.getView(i, itemView, null);
          if (itemView.getLayoutParams() == null)
              itemView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
          
          itemView.measure(widthMeasureSpec, heightMeasureSpec);
          width = Math.max(width, itemView.getMeasuredWidth());
      }

      // Add background padding to measured width
      if (background != null) {
          background.getPadding(mTempRect);
          width += mTempRect.left + mTempRect.right;
      }

      return width;
  }
 
开发者ID:XhinLiang,项目名称:MDPreference,代码行数:40,代码来源:Spinner.java

示例4: m2544a

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
private int m2544a(SpinnerAdapter spinnerAdapter, Drawable drawable) {
    if (spinnerAdapter == null) {
        return 0;
    }
    int makeMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
    int makeMeasureSpec2 = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
    int max = Math.max(0, getSelectedItemPosition());
    int min = Math.min(spinnerAdapter.getCount(), max + 15);
    int max2 = Math.max(0, max - (15 - (min - max)));
    View view = null;
    int i = 0;
    max = 0;
    while (max2 < min) {
        View view2;
        int itemViewType = spinnerAdapter.getItemViewType(max2);
        if (itemViewType != max) {
            view2 = null;
        } else {
            itemViewType = max;
            view2 = view;
        }
        view = spinnerAdapter.getView(max2, view2, this);
        if (view.getLayoutParams() == null) {
            view.setLayoutParams(new LayoutParams(-2, -2));
        }
        view.measure(makeMeasureSpec, makeMeasureSpec2);
        i = Math.max(i, view.getMeasuredWidth());
        max2++;
        max = itemViewType;
    }
    if (drawable == null) {
        return i;
    }
    drawable.getPadding(this.f1364l);
    return (this.f1364l.left + this.f1364l.right) + i;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:37,代码来源:bg.java

示例5: measureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
/**
 * Forked from android.widget.Spinner#measureContentWidth(SpinnerAdapter, Drawable).
 */
private int measureContentWidth(SpinnerAdapter spinnerAdapter) {
    if (spinnerAdapter == null) {
        return 0;
    }

    int width = 0;
    View itemView = null;
    int itemType = 0;
    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);

    // Make sure the number of items we'll measure is capped.
    // If it's a huge data set with wildly varying sizes, oh well.
    int start = 0;
    int end = Math.min(spinnerAdapter.getCount(), start + MAX_ITEMS_MEASURED);
    int count = end - start;
    start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
    ViewGroup parent = getToolbar().get();
    for (int i = start; i < end; i++) {
        int positionType = spinnerAdapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        itemView = spinnerAdapter.getView(i, itemView, parent);
        if (itemView.getLayoutParams() == null) {
            itemView.setLayoutParams(new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
        }
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        width = Math.max(width, itemView.getMeasuredWidth());
    }

    return width;
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:40,代码来源:ThreadListActivity.java

示例6: compatMeasureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
private int compatMeasureContentWidth(SpinnerAdapter paramSpinnerAdapter, Drawable paramDrawable)
{
  int i;
  if (paramSpinnerAdapter == null) {
    i = 0;
  }
  do
  {
    return i;
    i = 0;
    View localView = null;
    int j = 0;
    int k = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
    int m = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
    int n = Math.max(0, getSelectedItemPosition());
    int i1 = Math.min(paramSpinnerAdapter.getCount(), n + 15);
    for (int i2 = Math.max(0, n - (15 - (i1 - n))); i2 < i1; i2++)
    {
      int i3 = paramSpinnerAdapter.getItemViewType(i2);
      if (i3 != j)
      {
        j = i3;
        localView = null;
      }
      localView = paramSpinnerAdapter.getView(i2, localView, this);
      if (localView.getLayoutParams() == null) {
        localView.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
      }
      localView.measure(k, m);
      i = Math.max(i, localView.getMeasuredWidth());
    }
  } while (paramDrawable == null);
  paramDrawable.getPadding(this.mTempRect);
  return i + (this.mTempRect.left + this.mTempRect.right);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:36,代码来源:AppCompatSpinner.java

示例7: onMeasure

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int selectedPosition = getSelectedItemPosition();
    SpinnerAdapter adapter = getAdapter();
    if (selectedPosition >= 0 && adapter != null && selectedPosition < adapter.getCount()) {
        View view = adapter.getView(selectedPosition, null, this);
        measureChild(view, widthMeasureSpec, heightMeasureSpec);
        float padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, ARROW_PADDING,
                getResources().getDisplayMetrics());
        setMeasuredDimension(Math.min((int) (view.getMeasuredWidth() + padding),
                MeasureSpec.getSize(widthMeasureSpec)), getMeasuredHeight());
    }
}
 
开发者ID:googlesamples,项目名称:attendee-checkin,代码行数:15,代码来源:FlexSpinner.java

示例8: measureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
int measureContentWidth(SpinnerAdapter adapter, Drawable background) {
    if (adapter == null) {
        return 0;
    }

    int width = 0;
    View itemView = null;
    int itemType = 0;
    final int widthMeasureSpec =
        MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec =
        MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

    // Make sure the number of items we'll measure is capped. If it's a huge data set
    // with wildly varying sizes, oh well.
    int start = Math.max(0, getSelectedItemPosition());
    final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
    final int count = end - start;
    start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
    for (int i = start; i < end; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        itemView = adapter.getView(i, itemView, this);
        if (itemView.getLayoutParams() == null) {
            itemView.setLayoutParams(new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
        }
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        width = Math.max(width, itemView.getMeasuredWidth());
    }

    // Add background padding to measured width
    if (background != null) {
        background.getPadding(mTempRect);
        width += mTempRect.left + mTempRect.right;
    }

    return width;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:44,代码来源:IcsSpinner.java

示例9: compatMeasureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
private int compatMeasureContentWidth(SpinnerAdapter adapter, Drawable background) {
    if (adapter == null) {
        return 0;
    }

    int width = 0;
    View itemView = null;
    int itemType = 0;
    final int widthMeasureSpec =
            MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec =
            MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.UNSPECIFIED);

    // Make sure the number of items we'll measure is capped. If it's a huge data set
    // with wildly varying sizes, oh well.
    int start = Math.max(0, getSelectedItemPosition());
    final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
    final int count = end - start;
    start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
    for (int i = start; i < end; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        itemView = adapter.getView(i, itemView, this);
        if (itemView.getLayoutParams() == null) {
            itemView.setLayoutParams(new LayoutParams(
                    LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
        }
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        width = Math.max(width, itemView.getMeasuredWidth());
    }

    // Add background padding to measured width
    if (background != null) {
        background.getPadding(mTempRect);
        width += mTempRect.left + mTempRect.right;
    }

    return width;
}
 
开发者ID:GigigoGreenLabs,项目名称:permissionsModule,代码行数:44,代码来源:AppCompatSpinner.java

示例10: measureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
int measureContentWidth(SpinnerAdapter adapter, Drawable background) {
    if (adapter == null) {
        return 0;
    }

    int width = 0;
    View itemView = null;
    int itemType = 0;
    final int widthMeasureSpec =
        MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec =
        MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

    // Make sure the number of items we'll measure is capped. If it's a huge data set
    // with wildly varying sizes, oh well.
    int start = Math.max(0, getSelectedItemPosition());
    final int end = Math.min(adapter.getCount(), start + MAX_ITEMS_MEASURED);
    final int count = end - start;
    start = Math.max(0, start - (MAX_ITEMS_MEASURED - count));
    for (int i = start; i < end; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        itemView = adapter.getView(i, itemView, this);
        if (itemView.getLayoutParams() == null) {
            itemView.setLayoutParams(new LayoutParams(
                    LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
        }
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        width = Math.max(width, itemView.getMeasuredWidth());
    }

    // Add background padding to measured width
    if (background != null) {
        background.getPadding(mTempRect);
        width += mTempRect.left + mTempRect.right;
    }

    return width;
}
 
开发者ID:Aptoide,项目名称:aptoide-backup-apps,代码行数:44,代码来源:IcsSpinner.java

示例11: a

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
final int a(SpinnerAdapter paramSpinnerAdapter, Drawable paramDrawable)
{
  if (paramSpinnerAdapter == null) {
    return 0;
  }
  int m = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
  int n = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
  int i1 = Math.max(0, getSelectedItemPosition());
  int i2 = Math.min(paramSpinnerAdapter.getCount(), i1 + 15);
  int i3 = Math.max(0, i1 - (15 - (i2 - i1)));
  View localView1 = null;
  int i4 = 0;
  int i5 = 0;
  int i6;
  if (i3 < i2)
  {
    i6 = paramSpinnerAdapter.getItemViewType(i3);
    if (i6 == i5) {
      break label206;
    }
  }
  for (View localView2 = null;; localView2 = localView1)
  {
    localView1 = paramSpinnerAdapter.getView(i3, localView2, this);
    if (localView1.getLayoutParams() == null) {
      localView1.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
    }
    localView1.measure(m, n);
    i4 = Math.max(i4, localView1.getMeasuredWidth());
    i3++;
    i5 = i6;
    break;
    if (paramDrawable != null)
    {
      paramDrawable.getPadding(this.d);
      return i4 + (this.d.left + this.d.right);
    }
    return i4;
    label206:
    i6 = i5;
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:43,代码来源:adk.java

示例12: compatMeasureContentWidth

import android.widget.SpinnerAdapter; //导入方法依赖的package包/类
private int compatMeasureContentWidth(SpinnerAdapter spinneradapter, Drawable drawable)
{
    int j;
    if (spinneradapter == null)
    {
        j = 0;
    } else
    {
        int i = 0;
        View view = null;
        int k = 0;
        int j1 = android.view.View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
        int k1 = android.view.View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
        j = Math.max(0, getSelectedItemPosition());
        int l1 = Math.min(spinneradapter.getCount(), j + 15);
        for (j = Math.max(0, j - (15 - (l1 - j))); j < l1;)
        {
            int i1 = spinneradapter.getItemViewType(j);
            int l = k;
            if (i1 != k)
            {
                l = i1;
                view = null;
            }
            view = spinneradapter.getView(j, view, this);
            if (view.getLayoutParams() == null)
            {
                view.setLayoutParams(new android.view.ViewGroup.LayoutParams(-2, -2));
            }
            view.measure(j1, k1);
            i = Math.max(i, view.getMeasuredWidth());
            j++;
            k = l;
        }

        j = i;
        if (drawable != null)
        {
            drawable.getPadding(mTempRect);
            return i + (mTempRect.left + mTempRect.right);
        }
    }
    return j;
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:45,代码来源:AppCompatSpinner.java


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