當前位置: 首頁>>代碼示例>>Java>>正文


Java SpinnerAdapter.getItemViewType方法代碼示例

本文整理匯總了Java中android.widget.SpinnerAdapter.getItemViewType方法的典型用法代碼示例。如果您正苦於以下問題:Java SpinnerAdapter.getItemViewType方法的具體用法?Java SpinnerAdapter.getItemViewType怎麽用?Java SpinnerAdapter.getItemViewType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.SpinnerAdapter的用法示例。


在下文中一共展示了SpinnerAdapter.getItemViewType方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例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 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

示例9: 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

示例10: 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.getItemViewType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。