當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。