Example usage for android.widget CompoundButton.OnCheckedChangeListener CompoundButton.OnCheckedChangeListener

List of usage examples for android.widget CompoundButton.OnCheckedChangeListener CompoundButton.OnCheckedChangeListener

Introduction

In this page you can find the example usage for android.widget CompoundButton.OnCheckedChangeListener CompoundButton.OnCheckedChangeListener.

Prototype

CompoundButton.OnCheckedChangeListener

Source Link

Usage

From source file:io.oceanos.shaderbox.dialog.PropertiesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    final Shader shader = (Shader) getArguments().getSerializable("shader");

    View view = inflater.inflate(R.layout.dialog_properties, null);
    final EditText nameView = (EditText) view.findViewById(R.id.name);
    Switch vrMode = (Switch) view.findViewById(R.id.vr_mode);
    Switch preview = (Switch) view.findViewById(R.id.preview);
    Spinner resolutionFactor = (Spinner) view.findViewById(R.id.resolution_factor);
    resolutionFactor.setSelection(Integer.numberOfTrailingZeros(shader.getResolution()));
    resolutionFactor.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override/*from www .ja  v  a  2s. co m*/
        public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) {
            shader.setResolution(1 << pos);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });

    nameView.setText(shader.getName());

    vrMode.setChecked(shader.getVrMode() == 1);
    vrMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            shader.setVrMode(isChecked ? 1 : 0);
        }
    });

    preview.setChecked(shader.getPreviewMode() == 1);
    preview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            shader.setPreviewMode(isChecked ? 1 : 0);
        }
    });

    builder.setTitle(R.string.properties).setView(view)
            .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    shader.setName(nameView.getText().toString());
                    mListener.onSave(shader);
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    mListener.onCancel(shader);
                }
            });

    return builder.create();
}

From source file:mx.klozz.xperience.tweaker.fragments.VoltageControlSettings.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.voltage_settings, root, false);

    final ListView listView = (ListView) view.findViewById(R.id.ListView);
    final Switch setOnBoot = (Switch) view.findViewById(R.id.applyAtBoot);

    if (mVoltages.isEmpty()) {
        (view.findViewById(R.id.emptyList)).setVisibility(View.VISIBLE);
        (view.findViewById(R.id.BottomBar)).setVisibility(View.GONE);
    }//w  w w  . j  ava  2s  .com

    setOnBoot.setChecked(mPreferences.getBoolean(VOLTAGE_SOB, false));
    setOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mPreferences.edit().putBoolean(VOLTAGE_SOB, isChecked).apply();
            if (isChecked) {
                String warningMessage = getString(R.string.volt_info);

                new AlertDialog.Builder(context).setMessage(warningMessage)
                        .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                setOnBoot.setChecked(false);
                            }
                        }).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).create().show();
            }

        }
    });

    (view.findViewById(R.id.applyBtn)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            final StringBuilder sb = new StringBuilder();
            final String vdd = Helpers.getVoltagePath();
            if (vdd.equals(VDD_PATH)) {
                for (final Voltage volt : mVoltages) {
                    if (!volt.getSavedMV().equals(volt.getCurrentMv())) {
                        for (int i = 0; i < Helpers.getNumOfCPUS(); i++) {
                            sb.append("busybox echo \"").append(volt.getFreq()).append(" ")
                                    .append(volt.getSavedMV()).append("\" > ")
                                    .append(vdd.replace("cpu0", "cpu" + i)).append(";\n");
                        }
                    }
                }
            } else if (vdd.equals(VDD_TABLE)) {
                for (final Voltage volt : mVoltages) {
                    if (!volt.getSavedMV().equals(volt.getCurrentMv())) {
                        sb.append("busybox echo \"").append(volt.getFreq()).append(" ")
                                .append(volt.getSavedMV()).append("\" > ").append(vdd).append(";\n");
                    }
                }
            } else {
                final StringBuilder b = new StringBuilder();
                for (final Voltage volt : mVoltages) {
                    b.append(volt.getSavedMV()).append(" ");
                }
                if (vdd.equals(COMMON_VDD_PATH)) {
                    sb.append("busybox echo \"").append(b.toString()).append("\" > ").append(vdd).append(";\n");
                } else {
                    for (int i = 0; i < Helpers.getNumOfCPUS(); i++) {
                        sb.append("busybox echo \"").append(b.toString()).append("\" > ")
                                .append(vdd.replace("cpu0", "cpu" + i)).append(";\n");
                    }
                }
            }
            Helpers.shExec(sb, context, true);

            final List<Voltage> volts = getVolts(mPreferences);
            mVoltages.clear();
            mVoltages.addAll(volts);
            mAdapter.notifyDataSetChanged();
        }
    });

    mAdapter.setListItems(mVoltages);
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mVoltage = mVoltages.get(position);
            showDialog(vmin, vstep, nvsteps);
        }
    });

    return view;
}

From source file:nz.ac.auckland.lablet.script.components.TextComponent.java

@Override
public View createView(Context context, android.support.v4.app.Fragment parent) {
    CheckBox view = new CheckBox(context);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        view.setTextAppearance(android.R.style.TextAppearance_Medium);
        view.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color, null));
    } else {//from w w w .  j  a v a2s.co m
        view.setTextAppearance(context, android.R.style.TextAppearance_Medium);
        view.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color));
    }
    view.setText(text);

    if (getState() == ScriptTreeNode.SCRIPT_STATE_DONE)
        view.setChecked(true);

    view.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            if (checked)
                setState(ScriptTreeNode.SCRIPT_STATE_DONE);
            else
                setState(ScriptTreeNode.SCRIPT_STATE_ONGOING);
        }
    });
    return view;
}

From source file:eu.vranckaert.worktime.activities.account.AccountRegisterActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.activity_account_register);
    setSupportProgressBarIndeterminateVisibility(false);

    setTitle(R.string.lbl_account_register_title);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    tracker = AnalyticsTracker.getInstance(getApplicationContext());
    tracker.trackPageView(TrackerConstants.PageView.ACCOUNT_REGISTER_ACTIVITY);

    showPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override// w w w  . j  a v a2  s. c o  m
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                TransformationMethod tm = new TransformationMethod() {
                    @Override
                    public CharSequence getTransformation(CharSequence source, View view) {
                        return source;
                    }

                    @Override
                    public void onFocusChanged(View view, CharSequence sourceText, boolean focused,
                            int direction, Rect previouslyFocusedRect) {
                    }
                };

                password.setTransformationMethod(tm);
                passwordConfirmation.setTransformationMethod(tm);
            } else {
                password.setTransformationMethod(new PasswordTransformationMethod());
                passwordConfirmation.setTransformationMethod(new PasswordTransformationMethod());
            }
        }
    });

    registerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (validateInput()) {
                AsyncHelper.startWithParams(new RegisterTask(),
                        new String[] { email.getText().toString(), firstName.getText().toString(),
                                lastName.getText().toString(), password.getText().toString() });
            }
        }
    });
}

From source file:com.github.michalbednarski.intentslab.providerlab.AdvancedQueryActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.advanced_query);

    Intent intent = getIntent();/*from  w w  w. ja v  a 2  s  .  co m*/
    Bundle instanceStateOrExtras = savedInstanceState != null ? savedInstanceState : intent.getExtras();
    if (instanceStateOrExtras == null) {
        instanceStateOrExtras = Bundle.EMPTY;
    }

    // Uri
    mUriTextView = (AutoCompleteTextView) findViewById(R.id.uri);
    if (intent.getData() != null) {
        mUriTextView.setText(intent.getDataString());
    }
    mUriTextView.setAdapter(new UriAutocompleteAdapter(this));

    // Projection
    {
        mSpecifyProjectionCheckBox = (CheckBox) findViewById(R.id.specify_projection);
        mProjectionLayout = (LinearLayout) findViewById(R.id.projection_columns);

        // Bind events for master CheckBox and add new button
        findViewById(R.id.new_projection_column).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new UserProjectionColumn("");
            }
        });
        mSpecifyProjectionCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mProjectionLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            }
        });

        // Get values to fill
        String[] availableProjectionColumns = intent.getStringArrayExtra(EXTRA_PROJECTION_AVAILABLE_COLUMNS);
        String[] specifiedProjectionColumns = instanceStateOrExtras.getStringArray(EXTRA_PROJECTION);

        if (specifiedProjectionColumns == null) {
            mSpecifyProjectionCheckBox.setChecked(false);
        }

        if (availableProjectionColumns != null && availableProjectionColumns.length == 0) {
            availableProjectionColumns = null;
        }
        if (availableProjectionColumns != null && specifiedProjectionColumns == null) {
            specifiedProjectionColumns = availableProjectionColumns;
        }

        // Create available column checkboxes
        int i = 0;
        if (availableProjectionColumns != null) {
            for (String availableProjectionColumn : availableProjectionColumns) {
                boolean isChecked = i < specifiedProjectionColumns.length
                        && availableProjectionColumn.equals(specifiedProjectionColumns[i]);
                new DefaultProjectionColumn(availableProjectionColumn, isChecked);
                if (isChecked) {
                    i++;
                }
            }
        }

        // Create user column text fields
        if (specifiedProjectionColumns != null && i < specifiedProjectionColumns.length) {
            for (int il = specifiedProjectionColumns.length; i < il; i++) {
                new UserProjectionColumn(specifiedProjectionColumns[i]);
            }
        }

    }

    // Selection
    {
        // Find views
        mSelectionCheckBox = (CheckBox) findViewById(R.id.selection_header);
        mSelectionText = (TextView) findViewById(R.id.selection);
        mSelectionLayout = findViewById(R.id.selection_layout);
        mSelectionArgsTable = (TableLayout) findViewById(R.id.selection_args);

        // Bind events for add button and master CheckBox
        findViewById(R.id.selection_add_arg).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new SelectionArg("", true);
            }
        });
        mSelectionCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mSelectionLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            }
        });

        // Fill selection text view and CheckBox
        String selection = intent.getStringExtra(EXTRA_SELECTION);
        String[] selectionArgs = instanceStateOrExtras.getStringArray(EXTRA_SELECTION_ARGS);

        mSelectionCheckBox.setChecked(selection != null);
        if (selection != null) {
            mSelectionText.setText(selection);
        }

        // Fill selection arguments
        if ((selection != null || savedInstanceState != null) && selectionArgs != null
                && selectionArgs.length != 0) {
            for (String selectionArg : selectionArgs) {
                new SelectionArg(selectionArg);
            }
        }
    }

    // Content values
    {
        // Find views
        mContentValuesHeader = (TextView) findViewById(R.id.content_values_header);
        mContentValuesTable = (TableLayout) findViewById(R.id.content_values);
        mContentValuesTableHeader = (TableRow) findViewById(R.id.content_values_table_header);

        // Bind add new button event
        findViewById(R.id.new_content_value).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new ContentValue("", "", true);
            }
        });

        // Create table
        ContentValues contentValues = instanceStateOrExtras.getParcelable(EXTRA_CONTENT_VALUES);
        if (contentValues != null) {
            contentValues.valueSet();
            for (String key : Utils.getKeySet(contentValues)) {
                new ContentValue(key, contentValues.getAsString(key));
            }
        }
    }

    // Order
    {
        // Find views
        mSpecifyOrderCheckBox = (CheckBox) findViewById(R.id.specify_order);
        mOrderTextView = (TextView) findViewById(R.id.order);

        // Bind events
        mSpecifyOrderCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mOrderTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            }
        });

        // Fill fields
        String order = intent.getStringExtra(EXTRA_SORT_ORDER);
        if (order == null) {
            mSpecifyOrderCheckBox.setChecked(false);
        } else {
            mOrderTextView.setText(order);
        }
    }

    // Method (affects previous views so they must be initialized first)
    mMethodSpinner = (Spinner) findViewById(R.id.method);
    mMethodSpinner
            .setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, METHOD_NAMES));
    mMethodSpinner.setOnItemSelectedListener(onMethodSpinnerItemSelectedListener);
    mMethodSpinner.setSelection(intent.getIntExtra(EXTRA_METHOD, METHOD_QUERY));
}

From source file:com.javielinux.fragments.SearchAdvancedFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = View.inflate(getActivity(), R.layout.search_advanced_fragment, null);

    btInfoNotifications = (Button) view.findViewById(R.id.bt_info_notifications);
    btInfoNotifications.setOnClickListener(new View.OnClickListener() {
        @Override/* w w  w. j  ava 2s .  co  m*/
        public void onClick(View v) {
            String file = "notifications_use.txt";

            if (Locale.getDefault().getLanguage().equals("es")) {
                file = "notifications_use_es.txt";
            }

            try {
                AlertDialog builder = DialogUtils.PersonalDialogBuilder.create(getActivity(),
                        getActivity().getString(R.string.notifications), file);
                builder.show();
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
        }
    });

    languages = (Spinner) view.findViewById(R.id.sp_languages);
    attitude = (Spinner) view.findViewById(R.id.sp_attitude);
    filter = (Spinner) view.findViewById(R.id.sp_filter);
    noRetweet = (CheckBox) view.findViewById(R.id.cb_no_retweet);
    source = (EditText) view.findViewById(R.id.et_source);

    ArrayAdapter<?> adapterLanguages = ArrayAdapter.createFromResource(getActivity(), R.array.languages,
            android.R.layout.simple_spinner_item);
    adapterLanguages.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    languages.setAdapter(adapterLanguages);

    ArrayAdapter<?> adapterAttitude = ArrayAdapter.createFromResource(getActivity(), R.array.attitude,
            android.R.layout.simple_spinner_item);
    adapterAttitude.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    attitude.setAdapter(adapterAttitude);

    ArrayAdapter<?> adapterFilter = ArrayAdapter.createFromResource(getActivity(), R.array.filter,
            android.R.layout.simple_spinner_item);
    adapterFilter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    filter.setAdapter(adapterFilter);

    notifications = (CheckBox) view.findViewById(R.id.cb_notifications);
    notificationsBar = (CheckBox) view.findViewById(R.id.cb_notifications_bar);

    notifications.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                if (searchIsNotification) {
                    showFields();
                } else {
                    int max = Utils.MAX_NOTIFICATIONS;

                    if (Utils.isLite(getActivity())) {
                        max = Utils.MAX_NOTIFICATIONS_LITE;
                    }

                    int size = DataFramework.getInstance().getEntityList("search", "notifications=1").size()
                            + 1;

                    if (size <= max) {
                        showFields();
                    } else {
                        notifications.setChecked(false);
                        if (Utils.isLite(getActivity())) {
                            Utils.showMessage(getActivity(),
                                    getActivity().getString(R.string.max_notifications_lite));
                        } else {
                            Utils.showMessage(getActivity(),
                                    getActivity().getString(R.string.max_notifications));
                        }
                    }
                }
            } else {
                hideFields();
            }
        }

    });

    populateFields();

    return view;
}

From source file:org.thaliproject.nativetest.app.fragments.SettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_settings, container, false);

    mSettings = Settings.getInstance(view.getContext());
    mSettings.load();/*from w w w.j  a  va  2 s  . c o  m*/

    mConnectionTimeoutEditText = (EditText) view.findViewById(R.id.connectionTimeoutEditText);
    mConnectionTimeoutEditText.setText(String.valueOf(mSettings.getConnectionTimeout()));
    mConnectionTimeoutEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() > 0) {
                try {
                    mSettings.setConnectionTimeout(Long.parseLong(editable.toString()));
                } catch (NumberFormatException e) {
                    Log.e(TAG, e.getMessage(), e);
                    mConnectionTimeoutEditText.setText(String.valueOf(mSettings.getConnectionTimeout()));
                }
            }
        }
    });

    mPortNumberEditText = (EditText) view.findViewById(R.id.portNumberEditText);
    mPortNumberEditText.setText(String.valueOf(mSettings.getPortNumber()));
    mPortNumberEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() > 0 && !editable.toString().equals("-")) {
                try {
                    mSettings.setPortNumber(Integer.parseInt(editable.toString()));
                } catch (NumberFormatException e) {
                    Log.e(TAG, e.getMessage(), e);
                    mPortNumberEditText.setText(String.valueOf(mSettings.getPortNumber()));
                }
            }
        }
    });

    mListenForIncomingConnectionsCheckbox = (CheckBox) view
            .findViewById(R.id.listenForIncomingConnectionCheckbox);
    mListenForIncomingConnectionsCheckbox.setChecked(mSettings.getListenForIncomingConnections());
    mListenForIncomingConnectionsCheckbox
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    mSettings.setListenForIncomingConnections(b);
                }
            });

    mHandshakeRequiredCheckbox = (CheckBox) view.findViewById(R.id.handshakeRequiredCheckBox);
    mHandshakeRequiredCheckbox.setChecked(mSettings.getHandshakeRequired());
    mHandshakeRequiredCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mSettings.setHandshakeRequired(b);
        }
    });

    mEnableWifiCheckBox = (CheckBox) view.findViewById(R.id.enableWifiCheckBox);
    mEnableWifiCheckBox.setChecked(mSettings.getEnableWifiDiscovery());
    mEnableWifiCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mSettings.setEnableWifiDiscovery(b);
        }
    });

    mEnableBleCheckBox = (CheckBox) view.findViewById(R.id.enableBleCheckBox);
    mEnableBleCheckBox.setChecked(mSettings.getEnableBleDiscovery());
    mEnableBleCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mSettings.setEnableBleDiscovery(b);
        }
    });

    Spinner spinner = (Spinner) view.findViewById(R.id.advertiseModeSpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(view.getContext(),
            R.array.advertise_mode_string_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setSelection(mSettings.getAdvertiseMode());
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) {
            mSettings.setAdvertiseMode(index);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });

    spinner = (Spinner) view.findViewById(R.id.advertiseTxPowerLevelSpinner);
    adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.advertise_tx_power_level_string_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setSelection(mSettings.getAdvertiseTxPowerLevel());
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) {
            mSettings.setAdvertiseTxPowerLevel(index);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });

    spinner = (Spinner) view.findViewById(R.id.scanModeSpinner);
    adapter = ArrayAdapter.createFromResource(view.getContext(), R.array.scan_mode_string_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setSelection(mSettings.getScanMode());
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) {
            mSettings.setScanMode(index);
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });

    mBufferSizeEditText = (EditText) view.findViewById(R.id.bufferSizeEditText);
    mBufferSizeEditText.setText(String.valueOf(mSettings.getBufferSize()));
    mBufferSizeEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() > 0) {
                try {
                    mSettings.setBufferSize(Integer.parseInt(editable.toString()));
                } catch (NumberFormatException e) {
                    Log.e(TAG, e.getMessage(), e);
                    mBufferSizeEditText.setText(String.valueOf(mSettings.getBufferSize()));
                }
            }
        }
    });

    mDataAmountEditText = (EditText) view.findViewById(R.id.dataAmountEditText);
    mDataAmountEditText.setText(String.valueOf(mSettings.getDataAmount()));
    mDataAmountEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() > 0) {
                try {
                    mSettings.setDataAmount(Long.parseLong(editable.toString()));
                } catch (NumberFormatException e) {
                    Log.e(TAG, e.getMessage(), e);
                    mDataAmountEditText.setText(String.valueOf(mSettings.getDataAmount()));
                }
            }
        }
    });

    mEnableAutoConnectCheckBox = (CheckBox) view.findViewById(R.id.autoConnectCheckBox);
    mEnableAutoConnectCheckBox.setChecked(mSettings.getAutoConnect());
    mEnableAutoConnectCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mSettings.setAutoConnect(b);
        }
    });

    mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox = (CheckBox) view
            .findViewById(R.id.autoConnectEvenWhenIncomingCheckBox);
    mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox
            .setChecked(mSettings.getAutoConnectEvenWhenIncomingConnectionEstablished());
    mEnableAutoConnectEvenWhenIncomingConnectionEstablishedCheckBox
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    mSettings.setAutoConnectEvenWhenIncomingConnectionEstablished(b);
                }
            });

    return view;
}

From source file:com.javielinux.fragments.SearchGeoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = View.inflate(getActivity(), R.layout.search_geo_fragment, null);

    useGeo = (CheckBox) view.findViewById(R.id.cb_use_geo);
    typeGeo = (RadioGroup) view.findViewById(R.id.rg_type_geo);
    typeGeoGPS = (RadioButton) view.findViewById(R.id.rb_use_gps);
    typeGeoMap = (RadioButton) view.findViewById(R.id.rb_use_map);
    typeDistance = (RadioGroup) view.findViewById(R.id.rg_type_distance);
    typeDistanceMiles = (RadioButton) view.findViewById(R.id.rb_distance_miles);
    typeDistanceKM = (RadioButton) view.findViewById(R.id.rb_distance_km);

    llLocation = (LinearLayout) view.findViewById(R.id.ll_location);
    llMap = (LinearLayout) view.findViewById(R.id.ll_map);
    llDistance = (LinearLayout) view.findViewById(R.id.ll_distance);

    place = (AutoCompleteTextView) view.findViewById(R.id.et_place);

    address_list = new ArrayList<Address>();
    address_adapter = new AddressAdapter(getActivity(), address_list);
    place.setAdapter(address_adapter);// w w  w .j  a  va  2 s.c  o  m

    place.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Address address = address_adapter.getAddressItem(i);

            if (address != null) {
                latitude.setText(String.valueOf(address.getLatitude()));
                longitude.setText(String.valueOf(address.getLongitude()));
            }
        }
    });

    latitude = (EditText) view.findViewById(R.id.et_latitude);
    longitude = (EditText) view.findViewById(R.id.et_longitude);
    distance = (SeekBar) view.findViewById(R.id.sb_distance);
    distanceTxt = (TextView) view.findViewById(R.id.distance);

    distance.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
            changeTextDistance(arg1);
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {
        }
    });

    useGeo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showFields();
            } else {
                hideFields();
            }
        }
    });

    typeGeoGPS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                hideFieldsMap();
            }
        }
    });

    typeGeoMap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showFieldsMap();
            }
        }
    });

    typeDistanceMiles.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reloadTextDistance();
        }
    });

    typeDistanceKM.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reloadTextDistance();
        }
    });

    place.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String currentText = place.getText().toString();

            if (currentText.length() >= 3)
                APITweetTopics.execute(getActivity(), getLoaderManager(), SearchGeoFragment.this,
                        new GetGeolocationAddressRequest(getActivity(), currentText, false));
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable editable) {
        }
    });

    populateFields();

    return view;
}

From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuthAll.java

@Override
public void onResume() {
    super.onResume();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        final CheckBox cbYesAlready = (CheckBox) d.findViewById(R.id.rcm_cb_all);

        positiveButton.setEnabled(cbYesAlready.isChecked());

        OnCheckedChangeListener l = new CompoundButton.OnCheckedChangeListener() {
            @Override//from  w  ww  . ja  v a2s.  c o m
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                positiveButton.setEnabled(cbYesAlready.isChecked());
            }
        };
        cbYesAlready.setOnCheckedChangeListener(l);
    }
}

From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuth.java

@Override
public void onResume() {
    super.onResume();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        final RadioButton rbPre = (RadioButton) d.findViewById(R.id.rcm_rb_pre);
        final RadioButton rbAll = (RadioButton) d.findViewById(R.id.rcm_rb_all);

        all = rbAll.isChecked();//from  www .  ja  v  a 2 s. c  om

        positiveButton.setEnabled(rbPre.isChecked() || rbAll.isChecked());

        OnCheckedChangeListener l = new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                positiveButton.setEnabled(rbPre.isChecked() || rbAll.isChecked());
                all = rbAll.isChecked();
            }
        };

        rbPre.setOnCheckedChangeListener(l);
        rbAll.setOnCheckedChangeListener(l);
    }
}