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