當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewGroup.getTag方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:fashare2015,項目名稱:MVVM-JueJin,代碼行數:24,代碼來源:ViewGroupAdapter.java

示例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());
    }
}
 
開發者ID:DSM-DMS,項目名稱:DMS,代碼行數:23,代碼來源:CalendarView.java

示例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;
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:22,代碼來源:ThemeableActivity.java

示例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);
        }
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:34,代碼來源:AttachmentsViewBinder.java

示例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);
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:15,代碼來源:PopupNotificationActivity.java

示例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);
        }
    }
}
 
開發者ID:ghnor,項目名稱:StatusBarFits,代碼行數:33,代碼來源:StatusBarFits.java

示例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);
            }
        }
    }
}
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:53,代碼來源:StatusBarCompat.java

示例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);
            }
        }
    }
}
 
開發者ID:ynztlxdeai,項目名稱:MVPtemplate,代碼行數:53,代碼來源:StatusBarCompat.java


注:本文中的android.view.ViewGroup.getTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。