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


Java View.setId方法代碼示例

本文整理匯總了Java中android.view.View.setId方法的典型用法代碼示例。如果您正苦於以下問題:Java View.setId方法的具體用法?Java View.setId怎麽用?Java View.setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.setId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: onBindView

import android.view.View; //導入方法依賴的package包/類
@Override
public void onBindView(View view) {
    TextView label = (TextView) view.findViewById(R.id.suw_items_title);
    label.setText(getTitle());

    TextView summaryView = (TextView) view.findViewById(R.id.suw_items_summary);
    CharSequence summary = getSummary();
    if (summary != null && summary.length() > 0) {
        summaryView.setText(summary);
        summaryView.setVisibility(View.VISIBLE);
    } else {
        summaryView.setVisibility(View.GONE);
    }

    final View iconContainer = view.findViewById(R.id.suw_items_icon_container);
    final Drawable icon = getIcon();
    if (icon != null) {
        final ImageView iconView = (ImageView) view.findViewById(R.id.suw_items_icon);
        // Set the image drawable to null before setting the state and level to avoid affecting
        // any recycled drawable in the ImageView
        iconView.setImageDrawable(null);
        iconView.setImageState(icon.getState(), false /* merge */);
        iconView.setImageLevel(icon.getLevel());
        iconView.setImageDrawable(icon);
        iconContainer.setVisibility(View.VISIBLE);
    } else {
        iconContainer.setVisibility(View.GONE);
    }

    view.setId(getViewId());
}
 
開發者ID:Trumeet,項目名稱:SetupWizardLibCompat,代碼行數:32,代碼來源:Item.java

示例3: addFixedView

import android.view.View; //導入方法依賴的package包/類
public void addFixedView(View view, boolean isRight) {
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    LayoutParams hsvParams = (LayoutParams) hsv_toolbar.getLayoutParams();
    if (view.getId() <= 0) {
        view.setId(getIdValue());
    }
    if (isRight) {
        params.addRule(ALIGN_PARENT_RIGHT);
        hsvParams.addRule(LEFT_OF, view.getId());
    } else {
        params.addRule(ALIGN_PARENT_LEFT);
        hsvParams.addRule(RIGHT_OF, view.getId());
    }
    addView(view, params);
    hsv_toolbar.setLayoutParams(hsvParams);
}
 
開發者ID:yangchaojiang,項目名稱:ChatKeyboard-master,代碼行數:17,代碼來源:EmoticonsToolBarView.java

示例4: getView

import android.view.View; //導入方法依賴的package包/類
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // set the item view
    if (convertView == null) {
        LayoutInflater layoutInflater
                = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = layoutInflater.inflate(
                R.layout.item_face_with_checkbox, parent, false);
    }
    convertView.setId(position);

    Uri uri = Uri.parse(StorageHelper.getFaceUri(
            faceIdList.get(position), PersonActivity.this));
    ((ImageView)convertView.findViewById(R.id.image_face)).setImageURI(uri);

    // set the checked status of the item
    CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.checkbox_face);
    if (longPressed) {
        checkBox.setVisibility(View.VISIBLE);

        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                faceChecked.set(position, isChecked);
            }
        });
        checkBox.setChecked(faceChecked.get(position));
    } else {
        checkBox.setVisibility(View.INVISIBLE);
    }

    return convertView;
}
 
開發者ID:interritus1996,項目名稱:memento-app,代碼行數:34,代碼來源:PersonActivity.java

示例5: addFixedToolItemView

import android.view.View; //導入方法依賴的package包/類
public void addFixedToolItemView(boolean isRight, int rec, final PageSetEntity pageSetEntity, OnClickListener onClickListener) {
    View toolBtnView = getCommonItemToolBtn();
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    LayoutParams hsvParams = (LayoutParams) hsv_toolbar.getLayoutParams();
    if (toolBtnView.getId() <= 0) {
        toolBtnView.setId(isRight ? R.id.id_toolbar_right : R.id.id_toolbar_left);
    }
    if (isRight) {
        params.addRule(ALIGN_PARENT_RIGHT);
        hsvParams.addRule(LEFT_OF, toolBtnView.getId());
    } else {
        params.addRule(ALIGN_PARENT_LEFT);
        hsvParams.addRule(RIGHT_OF, toolBtnView.getId());
    }
    addView(toolBtnView, params);
    hsv_toolbar.setLayoutParams(hsvParams);
    initItemToolBtn(toolBtnView, rec, pageSetEntity, onClickListener);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:EmoticonsToolBarView.java

示例6: addView

import android.view.View; //導入方法依賴的package包/類
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    int childSum = this.getChildCount();
    if(childSum > 1) {
        throw new IllegalStateException("can host only one direct child");
    } else {
        super.addView(child, index, params);
        android.widget.RelativeLayout.LayoutParams paramsChild;
        if(childSum == 0) {
            if(child.getId() < 0) {
                child.setId(ID_CHILD);
            }

            paramsChild = (android.widget.RelativeLayout.LayoutParams)child.getLayoutParams();
            paramsChild.addRule(12);
            child.setLayoutParams(paramsChild);
        } else if(childSum == 1) {
            paramsChild = (android.widget.RelativeLayout.LayoutParams)child.getLayoutParams();
            paramsChild.addRule(2, ID_CHILD);
            child.setLayoutParams(paramsChild);
        }

    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:FloatOnKeyboardLayout.java

示例7: addPanelLayout

import android.view.View; //導入方法依賴的package包/類
public void addPanelLayout(View panel){
    ViewGroup contentLayout = (ViewGroup) ((Activity)mContext).findViewById(android.R.id.content);
    View customRootView = contentLayout.getChildAt(0);
    contentLayout.removeView(customRootView);
    contentLayout.addView(this);

    panel.setId(R.id.panel_container);
    LayoutParams customRootParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    customRootParams.addRule(RelativeLayout.ABOVE,panel.getId());
    customRootView.setLayoutParams(customRootParams);

    LayoutParams panelParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,0);
    panelParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    panel.setLayoutParams(panelParams);
    addView(panel);
    addView(customRootView);
    mPanelManager.closePanel();
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:19,代碼來源:IMERootLayout.java

示例8: addViewToCellLayout

import android.view.View; //導入方法依賴的package包/類
public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params,
        boolean markCells) {
    final LayoutParams lp = params;

    // Hotseat icons - remove text
    if (child instanceof BubbleTextView) {
        BubbleTextView bubbleChild = (BubbleTextView) child;
        bubbleChild.setTextVisibility(mContainerType != HOTSEAT);
    }

    child.setScaleX(mChildScale);
    child.setScaleY(mChildScale);

    // Generate an id for each view, this assumes we have at most 256x256 cells
    // per workspace screen
    if (lp.cellX >= 0 && lp.cellX <= mCountX - 1 && lp.cellY >= 0 && lp.cellY <= mCountY - 1) {
        // If the horizontal or vertical span is set to -1, it is taken to
        // mean that it spans the extent of the CellLayout
        if (lp.cellHSpan < 0) lp.cellHSpan = mCountX;
        if (lp.cellVSpan < 0) lp.cellVSpan = mCountY;

        child.setId(childId);
        mShortcutsAndWidgets.addView(child, index, lp);

        if (markCells) markCellsAsOccupiedForView(child);

        return true;
    }
    return false;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:31,代碼來源:CellLayout.java

示例9: onBindView

import android.view.View; //導入方法依賴的package包/類
@Override
public void onBindView(View view) {
    // Note: The efficiency could be improved by trying to recycle the buttons created by
    // ButtonItem
    final LinearLayout layout = (LinearLayout) view;
    layout.removeAllViews();

    for (ButtonItem buttonItem : mButtons) {
        Button button = buttonItem.createButton(layout);
        layout.addView(button);
    }

    view.setId(getViewId());
}
 
開發者ID:Trumeet,項目名稱:SetupWizardLibCompat,代碼行數:15,代碼來源:ButtonBarItem.java

示例10: getView

import android.view.View; //導入方法依賴的package包/類
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater layoutInflater =
                (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = layoutInflater.inflate(R.layout.item_log, parent, false);
    }
    convertView.setId(position);

    ((TextView)convertView.findViewById(R.id.log)).setText(log.get(position));

    return convertView;
}
 
開發者ID:interritus1996,項目名稱:memento-app,代碼行數:14,代碼來源:LogActivity.java

示例11: setId

import android.view.View; //導入方法依賴的package包/類
/**
 * set id
 *
 * @param view
 */
public static void setId(View view) {
    if (view != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            try {//samsung SM-N9009(4.3) crash here, so protected
                view.setId(View.generateViewId());
            } catch (Exception e) {
                view.setId(generateViewId());
            }
        } else {
            view.setId(generateViewId());
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:19,代碼來源:LuaViewUtil.java

示例12: getTargetView

import android.view.View; //導入方法依賴的package包/類
private View getTargetView(View v) {
    final String resourceName = getResources().getResourceEntryName(v.getId());

    if (resourceName.startsWith(ID_SIZE_SUFFIX) ||
        resourceName.startsWith(ID_DATE_SUFFIX)) {
        v.setId(R.id.first_position);
        return binding.txtLabelSize;

    } else if (resourceName.startsWith(ID_COLOR_SUFFIX) ||
        resourceName.startsWith(ID_TIME_SUFFIX)) {
        v.setId(R.id.second_position);
        return binding.txtLabelColour;
    }

    throw new IllegalStateException();
}
 
開發者ID:saulmm,項目名稱:From-design-to-Android-part1,代碼行數:17,代碼來源:OrderDialogFragment.java

示例13: createStatusBarView

import android.view.View; //導入方法依賴的package包/類
/**
 * 生成一個和狀態欄大小相同的半透明矩形條
 *
 * @param activity 需要設置的activity
 * @param color    狀態欄顏色值
 * @param alpha    透明值
 * @return 狀態欄矩形條
 */
private static View createStatusBarView(Activity activity, @ColorInt int color, int alpha) {
    // 繪製一個和狀態欄一樣高的矩形
    View statusBarView = new View(activity);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
    statusBarView.setLayoutParams(params);
    statusBarView.setBackgroundColor(calculateStatusColor(color, alpha));
    statusBarView.setId(FAKE_STATUS_BAR_VIEW_ID);
    return statusBarView;
}
 
開發者ID:wheat7,項目名稱:VRPlayer,代碼行數:19,代碼來源:StatusBarUtil.java

示例14: addItem

import android.view.View; //導入方法依賴的package包/類
private View addItem(ViewGroup holder, int layout, Item item) {
    View view = layoutInflater.inflate(layout, null);
    view.setId(item.getId());

    TextView tvLabel = (TextView) view.findViewById(R.id.label);
    ImageView ivIcon = (ImageView) view.findViewById(R.id.icon);

    Icon.on(ivIcon).bitmap(item.getIcon()).color(getIconColor()).put();

    tvLabel.setText(item.getLabel());
    view.setOnClickListener(item.getOnClick());

    RippleUtil.backgroundRipple(view, getCardColor());

    holder.addView(view);
    return view;
}
 
開發者ID:jrvansuita,項目名稱:MaterialAbout,代碼行數:18,代碼來源:AboutView.java

示例15: addRightView

import android.view.View; //導入方法依賴的package包/類
/**
 * 在 TopBar 的右側添加 View,如果此前已經有 View 通過該方法添加到 TopBar,則新添加進去的 View 會出現在已有View的左側
 *
 * @param view         要添加到 TopBar 右邊的 View
 * @param viewId       該按鈕的 id,可在 ids.xml 中找到合適的或新增。手工指定 viewId 是為了適應自動化測試。
 * @param layoutParams
 */
public void addRightView(View view, int viewId, LayoutParams layoutParams) {
    if (mRightLastViewId == DEFAULT_VIEW_ID) {
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        layoutParams.addRule(RelativeLayout.LEFT_OF, mRightLastViewId);
    }
    layoutParams.alignWithParent = true; // alignParentIfMissing
    mRightLastViewId = viewId;
    view.setId(viewId);
    mRightViewList.add(view);
    addView(view, layoutParams);

    // 消除按鈕變動對 titleView 造成的影響
    refreshTitleViewLp();
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:23,代碼來源:QMUITopBar.java


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