本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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();
}
示例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;
}
}
}
}
示例11: generateViewId
import android.view.View; //导入方法依赖的package包/类
public static int generateViewId() {
if (SysUtils.hasJellyBeanMr1()) {
return View.generateViewId();
} else {
return UUID.randomUUID().hashCode();
}
}
示例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);
}
}
示例13: generateHeaderId
import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public long generateHeaderId(int position) {
return View.generateViewId();
}