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


Java Switch.setText方法代码示例

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


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

示例1: getView

import android.widget.Switch; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    InstalledApp app = getItem(position);
    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_app, parent, false);
    }
    // Lookup view for data population


    appImage = (ImageView) convertView.findViewById(R.id.appImage);
    appPackage = (Switch) convertView.findViewById(R.id.appSwitch);
    appName = (TextView) convertView.findViewById(R.id.appName);
    appImage.setImageDrawable(app.image);
    appPackage.setText(app.packageName);
    appName.setText(app.name);

    // Return the completed view to render on screen
    return convertView;
}
 
开发者ID:mcosti,项目名称:notifications-forwarder,代码行数:22,代码来源:AppsAdapter.java

示例2: setupSwitches

import android.widget.Switch; //导入方法依赖的package包/类
private void setupSwitches() {
    Switch show_full_zen = view.findViewById(R.id.show_full_zen);
    Switch hu_notif = view.findViewById(R.id.hu_notif);
    Switch vol_warn = view.findViewById(R.id.vol_warn);
    Switch power_notifs = view.findViewById(R.id.power_notifications);
    Switch clock_seconds = view.findViewById(R.id.clock_seconds);
    Switch battery_percent = view.findViewById(R.id.battery_percent);
    CardView power_notif_controls = view.findViewById(R.id.power_notification_controls_card);

    //noinspection deprecation
    battery_percent.setText(Html.fromHtml(getResources().getText(R.string.battery_percentage) + "<br /><small> <font color=\"#777777\">" + getResources().getText(R.string.reboot_required) + "</font></small>"));

    if (Build.VERSION.SDK_INT > 23) {
        clock_seconds.setVisibility(View.VISIBLE); //only show switch if user is on Nougat or later
        power_notif_controls.setVisibility(View.VISIBLE); //this is a Nougat feature; only show it on Nougat devices
    } else {
        clock_seconds.setVisibility(View.GONE);
        power_notif_controls.setVisibility(View.GONE);
    }

    activity.setThings.switches(show_full_zen, SHOW_FULL_ZEN, SECURE, view); //switch listener
    activity.setThings.switches(hu_notif, HUN_ENABLED, GLOBAL, view);
    activity.setThings.switches(vol_warn, SAFE_AUDIO, GLOBAL, view);

    activity.setThings.switches(clock_seconds, CLOCK_SECONDS, SECURE, view);
    activity.setThings.switches(battery_percent, BATTERY_PERCENT, SYSTEM, view);

    activity.setThings.switches(power_notifs, POW_NOTIFS, SECURE, view);
}
 
开发者ID:zacharee,项目名称:SystemUITuner2,代码行数:30,代码来源:Misc.java

示例3: attachTranslation

import android.widget.Switch; //导入方法依赖的package包/类
private void attachTranslation(View view, TargetTextType type, String result){
    if (view instanceof EditText){
        if(type == TargetTextType.Hint){
            ((EditText)view).setHint(result);
        }else if(type == TargetTextType.Text){
            ((EditText)view).setText(result);
        }
    }else if (view instanceof ToggleButton){
        ToggleButton toggle = (ToggleButton)view;
        if(type == TargetTextType.TextOff){
            toggle.setTextOff(result);
            if(toggle.isChecked() == false){
                toggle.setText(result);
            }
        }else if(type == TargetTextType.TextOn){
            toggle.setTextOn(result);
            if(toggle.isChecked() == true){
                toggle.setText(result);
            }
        }else if(type == TargetTextType.Text){
            toggle.setText(result);
        }
    }else if (view instanceof Switch){
        Switch switchWidget = (Switch)view;
        if(type == TargetTextType.TextOff){
            switchWidget.setTextOff(result);
        }else if(type == TargetTextType.TextOn){
            switchWidget.setTextOn(result);
        }else if(type == TargetTextType.Text){
            switchWidget.setText(result);
        }
    }else if (view instanceof Button){
        ((Button)view).setText(result);
    }else if (view instanceof TextView){
        ((TextView)view).setText(result);
    }
}
 
开发者ID:mizutori,项目名称:InAppTranslation_Android,代码行数:38,代码来源:InAppTranslation.java

示例4: span

import android.widget.Switch; //导入方法依赖的package包/类
public static void span(String text, String subText, Switch switchView) {
    SpannableString spanText = new SpannableString(text);
    spanText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, text.length(), 0);
    spanText.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), 0);

    SpannableString spanSubText = new SpannableString(subText);
    spanSubText.setSpan(new RelativeSizeSpan(0.75f), 0, subText.length(), 0);
    spanSubText.setSpan(new ForegroundColorSpan(Color.GRAY), 0, subText.length(), 0);
    switchView.setText("");
    switchView.append(spanText);
    switchView.append("\n");
    switchView.append(spanSubText);
}
 
开发者ID:kerick-jeff,项目名称:MyBP,代码行数:14,代码来源:Span.java

示例5: populate

import android.widget.Switch; //导入方法依赖的package包/类
private void populate(final boolean enabled, List<DeviceActionDAO> defaultActions, List<StoryDeviceActionDAO> existingActions) {
    LinearLayout layout;
    if (enabled) {
        layout = findViewById(R.id.storyEnabledLinearLayout);
    } else {
        layout = findViewById(R.id.storyDisabledLinearLayout);
    }
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(0, 8, 0, 8);
    for (final DeviceActionDAO action : defaultActions) {
        Switch s = new Switch(this);
        s.setText(action.getName());
        s.setLayoutParams(lp);
        // Check the matching switch for every list
        for (StoryDeviceActionDAO existingAction : existingActions) {
            if (enabled && existingAction.isEnabled() && existingAction.getActionId() == action.getId()) {
                s.setChecked(true);
                break;
            } else if (!enabled && !existingAction.isEnabled() && existingAction.getActionId() == action.getId()) {
                s.setChecked(true);
                break;
            }
        }
        layout.addView(s);
        s.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
                if (checked) {
                    db.createActionForStoryAndDevice(storyId, enabled, action);
                } else {
                    db.deleteActionForStoryAndDevice(storyId, enabled, action);
                }
            }
        });
    }
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:37,代码来源:DeviceActivity.java


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