本文整理汇总了Java中android.view.ViewGroup.getTag方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.getTag方法的具体用法?Java ViewGroup.getTag怎么用?Java ViewGroup.getTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.getTag方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDataTwoWay
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* (伪)双向 databinding: 同 {@link RecyclerViewAdapter#setDataTwoWay(RecyclerView, ListVM, List)}
*
* @param container
* @param vm
* @param datas
* @param <T>
*/
@BindingAdapter({"vm", "data"})
public static <T> void setDataTwoWay(final ViewGroup container, final ListVM<T> vm, List<T> datas){
if(vm == null){
return ;
}
bind(container, vm, datas);
if(vm instanceof TwoWayListVM){
boolean isInited = container.getTag(R.id.db_inited) != null;
if(!isInited) {
container.setTag(R.id.db_inited, true);
loadData(container, (TwoWayListVM<T>)vm, null, null);
}
}
}
示例2: onClick
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
// Extract day selected
ViewGroup dayOfMonthContainer = (ViewGroup) view;
String tagId = (String) dayOfMonthContainer.getTag();
tagId = tagId.substring(mContext.getString(R.string.day_of_month_container).length(), tagId.length());
final TextView dayOfMonthText = (TextView) view.findViewWithTag(mContext.getString(R.string.day_of_month_text) + tagId);
// Fire event
final Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(mFirstDayOfWeek);
calendar.setTime(mCalendar.getTime());
calendar.set(Calendar.DAY_OF_MONTH, Integer.valueOf(dayOfMonthText.getText().toString()));
setDateAsSelected(calendar.getTime());
//Set the current day color
setCurrentDay(mCalendar.getTime());
if (mOnDateClickListener != null) {
mOnDateClickListener.onDateClick(calendar.getTime());
}
}
示例3: findViewsWithTag
import android.view.ViewGroup; //导入方法依赖的package包/类
private static ArrayList<View> findViewsWithTag(String TAG, ViewGroup rootView,
ArrayList<View> views) {
Object tag = rootView.getTag();
if (tag != null && tag.equals(TAG)) {
views.add(rootView);
}
for (int i = 0; i < rootView.getChildCount(); i++) {
View v = rootView.getChildAt(i);
tag = v.getTag();
if (tag != null && tag.equals(TAG)) {
views.add(v);
}
if (v instanceof ViewGroup) {
findViewsWithTag(TAG, (ViewGroup) v, views);
}
}
return views;
}
示例4: displayVoiceMessages
import android.view.ViewGroup; //导入方法依赖的package包/类
private void displayVoiceMessages(final ArrayList<VoiceMessage> voices, ViewGroup container) {
if(Objects.isNull(container)) return;
boolean empty = safeIsEmpty(voices);
container.setVisibility(empty ? View.GONE : View.VISIBLE);
if (empty) {
return;
}
int i = voices.size() - container.getChildCount();
for (int j = 0; j < i; j++) {
container.addView(LayoutInflater.from(mContext).inflate(R.layout.item_voice_message, container, false));
}
for (int g = 0; g < container.getChildCount(); g++) {
ViewGroup root = (ViewGroup) container.getChildAt(g);
if (g < voices.size()) {
VoiceHolder holder = (VoiceHolder) root.getTag();
if(holder == null){
holder = new VoiceHolder(root);
root.setTag(holder);
}
final VoiceMessage voice = voices.get(g);
bindVoiceHolder(holder, voice);
root.setVisibility(View.VISIBLE);
} else {
root.setVisibility(View.GONE);
}
}
}
示例5: reuseView
import android.view.ViewGroup; //导入方法依赖的package包/类
private void reuseView(ViewGroup view) {
if (view == null) {
return;
}
int tag = (Integer)view.getTag();
view.setVisibility(View.GONE);
if (tag == 1) {
textViews.add(view);
} else if (tag == 2) {
imageViews.add(view);
} else if (tag == 3) {
audioViews.add(view);
}
}
示例6: setRootViewPaddingTop
import android.view.ViewGroup; //导入方法依赖的package包/类
private static void setRootViewPaddingTop(Activity activity, PaddingTop paddingTop) {
ViewGroup rootView =
(ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
if (paddingTop == PaddingTop.addPaddingTop) {
if (!ViewCompat.getFitsSystemWindows(rootView) ||
(rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_REMOVE_TOP))) {
if (rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_ADD_TOP)) {
return;
}
rootView.setPadding(
rootView.getPaddingLeft(),
rootView.getPaddingTop() + getStatusBarHeight(activity),
rootView.getPaddingRight(),
rootView.getPaddingBottom());
rootView.setTag(R.id.tag_top, TAG_ADD_TOP);
}
}
else if (paddingTop == PaddingTop.removePaddingTop) {
if (ViewCompat.getFitsSystemWindows(rootView) ||
(rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_ADD_TOP))) {
if (rootView.getTag(R.id.tag_top) != null && rootView.getTag(R.id.tag_top).equals(TAG_REMOVE_TOP)) {
return;
}
rootView.setPadding(
rootView.getPaddingLeft(),
rootView.getPaddingTop() - getStatusBarHeight(activity),
rootView.getPaddingRight(),
rootView.getPaddingBottom());
rootView.setTag(R.id.tag_top, TAG_REMOVE_TOP);
}
}
}
示例7: translucentStatusBar
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* change to full screen mode
* @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it
*/
public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
Window window = activity.getWindow();
ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
//set child View not fill the system window
View mChildView = mContentView.getChildAt(0);
if (mChildView != null) {
ViewCompat.setFitsSystemWindows(mChildView, false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int statusBarHeight = getStatusBarHeight(activity);
//First translucent status bar.
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//After LOLLIPOP just set LayoutParams.
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (hideStatusBarBackground) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(COLOR_TRANSLUCENT);
} else {
window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA));
}
//must call requestApplyInsets, otherwise it will have space in screen bottom
if (mChildView != null) {
ViewCompat.requestApplyInsets(mChildView);
}
} else {
ViewGroup mDecorView = (ViewGroup) window.getDecorView();
if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean)mDecorView.getTag()) {
mChildView = mDecorView.getChildAt(0);
//remove fake status bar view.
mContentView.removeView(mChildView);
mChildView = mContentView.getChildAt(0);
if (mChildView != null) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams();
//cancel the margin top
if (lp != null && lp.topMargin >= statusBarHeight) {
lp.topMargin -= statusBarHeight;
mChildView.setLayoutParams(lp);
}
}
mDecorView.setTag(false);
}
}
}
}
示例8: translucentStatusBar
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* change to full screen mode
* @param hideStatusBarBackground hide status bar alpha Background when SDK > 21, true if hide it
*/
public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
Window window = activity.getWindow();
ViewGroup mContentView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
//set child View not fill the system window
View mChildView = mContentView.getChildAt(0);
if (mChildView != null) {
ViewCompat.setFitsSystemWindows(mChildView, false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int statusBarHeight = getStatusBarHeight(activity);
//First translucent status bar.
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//After LOLLIPOP just set LayoutParams.
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (hideStatusBarBackground) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(COLOR_TRANSLUCENT);
} else {
window.setStatusBarColor(calculateStatusBarColor(COLOR_TRANSLUCENT, DEFAULT_COLOR_ALPHA));
}
//must call requestApplyInsets, otherwise it will have space in screen bottom
if (mChildView != null) {
ViewCompat.requestApplyInsets(mChildView);
}
} else {
ViewGroup mDecorView = (ViewGroup) window.getDecorView();
if (mDecorView.getTag() != null && mDecorView.getTag() instanceof Boolean && (Boolean)mDecorView.getTag()) {
mChildView = mDecorView.getChildAt(0);
//remove fake status bar view.
mContentView.removeView(mChildView);
mChildView = mContentView.getChildAt(0);
if (mChildView != null) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams();
//cancel the margin top
if (lp != null && lp.topMargin >= statusBarHeight) {
lp.topMargin -= statusBarHeight;
mChildView.setLayoutParams(lp);
}
}
mDecorView.setTag(false);
}
}
}
}