当前位置: 首页>>代码示例>>Java>>正文


Java CompoundButton.setId方法代码示例

本文整理汇总了Java中android.widget.CompoundButton.setId方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundButton.setId方法的具体用法?Java CompoundButton.setId怎么用?Java CompoundButton.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.CompoundButton的用法示例。


在下文中一共展示了CompoundButton.setId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onChildViewAdded

import android.widget.CompoundButton; //导入方法依赖的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

示例2: onBindViewHolder

import android.widget.CompoundButton; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RegionContainer.VH holder, final int position) {
    final NewConditionItem item = mList.get(position);
    if (holder.getItemViewType() == TYPE_EDIT) {
        CompoundButton btnEdit = holder.tb;
                btnEdit.setText(item.name);
        btnEdit.setChecked(item.selected);
        btnEdit.setTag(item);
        btnEdit.setId(holder.getItemViewType());
        btnEdit.setOnClickListener(mOnClickListener);
        final View finalView = btnEdit;
        final NewConditionItem finalitem =item;
        btnEdit.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnItemClickListener!= null) {
                   mOnItemClickListener.onEditClick(finalView, item.id);
                }
            }
        });

    } else {
        CompoundButton btn = holder.tb;
        btn.setText(item.name);
        btn.setChecked(item.selected);
        btn.setTag(item);
        btn.setId(holder.getItemViewType());
        btn.setOnClickListener(mOnClickListener);
    }

}
 
开发者ID:Tamicer,项目名称:FilterBar,代码行数:32,代码来源:RegionContainer.java

示例3: refreshSearchEngineViews

import android.widget.CompoundButton; //导入方法依赖的package包/类
private void refreshSearchEngineViews(Context context, SearchEngineManager sem) {
    if (searchEngineGroup == null) {
        // We want to refresh the search engine list of this preference in onResume,
        // but the first time this preference is created onResume is called before onCreateView
        // so searchEngineGroup is not set yet.
        return;
    }

    final String defaultSearchEngine = sem.getDefaultSearchEngine(context).getIdentifier();

    searchEngineGroup.removeAllViews();

    final LayoutInflater layoutInflater = LayoutInflater.from(context);
    final RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    for (int i = 0; i < searchEngines.size(); i++) {
        final SearchEngine engine = searchEngines.get(i);
        final String engineId = engine.getIdentifier();
        final CompoundButton engineItem = makeButtonFromSearchEngine(engine, layoutInflater, context.getResources());
        engineItem.setId(i);
        engineItem.setTag(engineId);
        if (engineId.equals(defaultSearchEngine)) {
            updateDefaultItem(engineItem);
        }
        searchEngineGroup.addView(engineItem, layoutParams);
    }
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:28,代码来源:SearchEngineListPreference.java


注:本文中的android.widget.CompoundButton.setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。