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


Java View.generateViewId方法代码示例

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


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

示例1: onChildViewAdded

import android.view.View; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onChildViewAdded(View parent, View child) {
    if (parent == RelativeRadioGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
开发者ID:mmb4rn0,项目名称:RelativeRadioGroup,代码行数:20,代码来源:RelativeRadioGroup.java

示例2: onChildViewAdded

import android.view.View; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void onChildViewAdded(View parent, View child) {
    if (parent == ToggleGroup.this && child instanceof CompoundButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
         if (Build.VERSION.SDK_INT < 17)
          id = child.hashCode();
         else
             id = View.generateViewId();
            child.setId(id);
        }
        ((CompoundButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
开发者ID:rcketscientist,项目名称:ToggleButtons,代码行数:22,代码来源:ToggleGroup.java

示例3: onChildViewAdded

import android.view.View; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onChildViewAdded(View parent, View child) {
    if (parent == NestRadioGroup.this) {

        final List<CompoundButton> list = findCheckedView(child);
        for(CompoundButton view : list){
            if (view != null) {
                int id = view.getId();
                // generates an id if it's missing
                if (id == View.NO_ID && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    id = View.generateViewId();
                    view.setId(id);
                }
                view.setOnCheckedChangeListener(mChildOnCheckedChangeListener);
            }
        }

    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
开发者ID:RealMoMo,项目名称:NestRadioGroup,代码行数:27,代码来源:NestRadioGroup.java

示例4: generateViewId

import android.view.View; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static int generateViewId() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        for (;;) {
            final int result = sNextGeneratedId.get();
            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
            int newValue = result + 1;
            if (newValue > 0x00FFFFFF)
                newValue = 1; // Roll over to 1, not 0.
            if (sNextGeneratedId.compareAndSet(result, newValue))
                return result;
        }
    }
    else
        return View.generateViewId();
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:17,代码来源:ViewUtil.java

示例5: generateViewId

import android.view.View; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static int generateViewId() {

  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
    for (;;) {
      final int result = sNextGeneratedId.get();
      // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
      int newValue = result + 1;
      if (newValue > 0x00FFFFFF)
        newValue = 1; // Roll over to 1, not 0.
      if (sNextGeneratedId.compareAndSet(result, newValue)) {
        return result;
      }
    }
  } else {
    return View.generateViewId();
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:19,代码来源:WXViewUtils.java

示例6: onChildViewAdded

import android.view.View; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void onChildViewAdded(View parent, View child) {
    if (parent == MultiRadioGroup.this ) {
        List<RadioButton> btns = getAllRadioButton(child);
        if(btns != null && btns.size() > 0){
            for(RadioButton btn : btns){
                int id = btn.getId();
                // generates an id if it's missing
                if (id == View.NO_ID && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    id = View.generateViewId();
                    btn.setId(id);
                }
                btn.setOnCheckedChangeListener(
                        mChildOnCheckedChangeListener);
            }
        }
    }
    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
开发者ID:JackWHLiu,项目名称:jackknife,代码行数:24,代码来源:MultiRadioGroup.java

示例7: getItemId

import android.view.View; //导入方法依赖的package包/类
@Override
public long getItemId(int position) {
    int id = mFragmentList.get(position).getId();
    if (id == 0) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            while (true) {
                final int result = sNextGeneratedId.get();
                // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
                int newValue = result + 1;
                if (newValue > 0x00FFFFFF)
                    newValue = 1; // Roll over to 1, not 0.
                if (sNextGeneratedId.compareAndSet(result, newValue)) {
                    id = result;
                    break;
                }
            }
        } else {
            id = View.generateViewId();
        }
    }
    mIdArray[position] = id;
    return id;
}
 
开发者ID:thaihuynhxyz,项目名称:recycler-view-pager,代码行数:24,代码来源:FragmentPagerAdapter.java

示例8: generateViewId

import android.view.View; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static int generateViewId() {

    if (Build.VERSION.SDK_INT < 17) {
        for (;;) {
            final int result = sNextGeneratedId.get();
            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
            int newValue = result + 1;
            if (newValue > 0x00FFFFFF)
                newValue = 1; // Roll over to 1, not 0.
            if (sNextGeneratedId.compareAndSet(result, newValue)) {
                return result;
            }
        }
    } else {
        return View.generateViewId();
    }

}
 
开发者ID:jrvansuita,项目名称:MaterialAbout,代码行数:20,代码来源:ViewIdGenerator.java

示例9: generateViewId

import android.view.View; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static int generateViewId() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        for (; ; ) {
            final int result = sNextGeneratedId.get();
            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
            int newValue = result + 1;
            if (newValue > 0x00FFFFFF)
                newValue = 1; // Roll over to 1, not 0.
            if (sNextGeneratedId.compareAndSet(result, newValue))
                return result;
        }
    } else
        return View.generateViewId();
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:16,代码来源:ViewUtil.java

示例10: generateViewId

import android.view.View; //导入方法依赖的package包/类
public static int generateViewId() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return View.generateViewId();
    } else {
        for (; ; ) {
            final int result = sNextGeneratedId.get();
            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
            int newValue = result + 1;
            if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
            if (sNextGeneratedId.compareAndSet(result, newValue)) {
                return result;
            }
        }
    }
}
 
开发者ID:coopese,项目名称:qmui,代码行数:16,代码来源:QMUIViewHelper.java

示例11: generateViewId

import android.view.View; //导入方法依赖的package包/类
public static int generateViewId() {
    if (SysUtils.hasJellyBeanMr1()) {
        return View.generateViewId();
    } else {
        return UUID.randomUUID().hashCode();
    }
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:8,代码来源:ViewFinder.java

示例12: onChildViewAdded

import android.view.View; //导入方法依赖的package包/类
public void onChildViewAdded(View parent, View child) {
    if (parent == CompoundFrameLayoutRadioGroup.this && child instanceof CompoundFrameLayout) {
        int id = child.getId();
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((CompoundFrameLayout) child).setOnCheckedChangeWidgetListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
开发者ID:S64,项目名称:android-radiobutton-extended,代码行数:15,代码来源:CompoundFrameLayoutRadioGroup.java

示例13: generateHeaderId

import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public long generateHeaderId(int position) {
    return View.generateViewId();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:UltimateGridLayoutAdapter.java


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