當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。