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


Java SwitchButton類代碼示例

本文整理匯總了Java中com.netease.nim.uikit.common.ui.widget.SwitchButton的典型用法代碼示例。如果您正苦於以下問題:Java SwitchButton類的具體用法?Java SwitchButton怎麽用?Java SwitchButton使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SwitchButton類屬於com.netease.nim.uikit.common.ui.widget包,在下文中一共展示了SwitchButton類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addToggleItemView

import com.netease.nim.uikit.common.ui.widget.SwitchButton; //導入依賴的package包/類
private SwitchButton addToggleItemView(String key, int titleResId, boolean initState) {
    ViewGroup vp = (ViewGroup) getLayoutInflater().inflate(R.layout.nim_user_profile_toggle_item, null);
    ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.isetting_item_height));
    vp.setLayoutParams(vlp);

    TextView titleText = ((TextView) vp.findViewById(R.id.user_profile_title));
    titleText.setText(titleResId);

    SwitchButton switchButton = (SwitchButton) vp.findViewById(R.id.user_profile_toggle);
    switchButton.setCheck(initState);
    switchButton.setOnChangedListener(onChangedListener);
    switchButton.setTag(key);

    toggleLayout.addView(vp);

    if (toggleStateMap == null) {
        toggleStateMap = new HashMap<>();
    }
    toggleStateMap.put(key, initState);
    return switchButton;
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:23,代碼來源:UserProfileActivity.java

示例2: addToggleItemView

import com.netease.nim.uikit.common.ui.widget.SwitchButton; //導入依賴的package包/類
private SwitchButton addToggleItemView(String key, int titleResId, boolean initState) {
    ViewGroup vp = (ViewGroup) getLayoutInflater().inflate(R.layout.nim_user_profile_toggle_item, null);
    ViewGroup.LayoutParams vlp = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.isetting_item_height));
    vp.setLayoutParams(vlp);

    TextView titleText = ((TextView) vp.findViewById(R.id.user_profile_title));
    titleText.setText(titleResId);

    SwitchButton switchButton = (SwitchButton) vp.findViewById(R.id.user_profile_toggle);
    switchButton.setCheck(initState);
    switchButton.setOnChangedListener(onChangedListener);
    switchButton.setTag(key);

    toggleLayout.addView(vp);

    return switchButton;
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:19,代碼來源:NormalTeamInfoActivity.java

示例3: createSwitchListener

import com.netease.nim.uikit.common.ui.widget.SwitchButton; //導入依賴的package包/類
private void createSwitchListener(final SettingTemplate item) {
    onchangeListener = new SwitchButton.OnChangedListener() {
        @Override
        public void OnChanged(View v, boolean checkState) {
            switchChangeListener.onSwitchChange(item, checkState);
        }
    };
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:9,代碼來源:SettingsAdapter.java

示例4: getView

import com.netease.nim.uikit.common.ui.widget.SwitchButton; //導入依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder = null;
    if(convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(layoutID, parent, false);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }
    if(viewHolder == null) {
        viewHolder = new ViewHolder();
        viewHolder.root = convertView;
        viewHolder.headImageView = (HeadImageView) convertView.findViewById(R.id.head_image);
        viewHolder.titleView = (TextView)  convertView.findViewById(R.id.title_label);
        viewHolder.detailView = (TextView) convertView.findViewById(R.id.detail_label);
        viewHolder.switchButton = (SwitchButton) convertView.findViewById(R.id.setting_item_toggle);
        viewHolder.line = convertView.findViewById(R.id.line);
        viewHolder.indicator = (ImageView) convertView.findViewById(R.id.setting_item_indicator);
        viewHolder.headTitleView = (TextView) convertView.findViewById(R.id.head_title_label);
        viewHolder.headDetailView = (TextView) convertView.findViewById(R.id.head_detail_label);
        convertView.setTag(viewHolder);
    }


    ViewGroup.LayoutParams lp = viewHolder.root.getLayoutParams();
    if(lp != null) {
        lp.height = itemHeight;
        viewHolder.root.setLayoutParams(lp);
    }
    viewHolder.root.setBackgroundResource(R.drawable.nim_semitransparency_selector);
    viewHolder.headImageView.setVisibility(View.GONE);
    viewHolder.titleView.setVisibility(View.GONE);
    viewHolder.detailView.setVisibility(View.GONE);
    viewHolder.switchButton.setVisibility(View.GONE);
    viewHolder.line.setVisibility(View.GONE);
    viewHolder.indicator.setVisibility(View.GONE);
    viewHolder.headTitleView.setVisibility(View.GONE);
    viewHolder.headDetailView.setVisibility(View.GONE);


    SettingTemplate item = items.get(position);
    if(item.getType() == SettingType.TYPE_TOGGLE) {
        updateToggleItem(viewHolder, item, position);
    } else if(item.getType() == SettingType.TYPE_HEAD) {
        updateHeadItem(viewHolder);
    } else if(item.getType() == SettingType.TYPE_SEPERATOR) {
        updateSeperatorItem(viewHolder);
    } else if(item.getType() == SettingType.TYPE_LINE) {
        addLineItem(viewHolder);
    } else {
        updateDefaultItem(viewHolder, item, position);
    }

    return convertView;
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:56,代碼來源:SettingsAdapter.java

示例5: setToggleBtn

import com.netease.nim.uikit.common.ui.widget.SwitchButton; //導入依賴的package包/類
private void setToggleBtn(SwitchButton btn, boolean isChecked) {
    btn.setCheck(isChecked);
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:4,代碼來源:UserProfileActivity.java


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