Example usage for android.text.method PasswordTransformationMethod PasswordTransformationMethod

List of usage examples for android.text.method PasswordTransformationMethod PasswordTransformationMethod

Introduction

In this page you can find the example usage for android.text.method PasswordTransformationMethod PasswordTransformationMethod.

Prototype

PasswordTransformationMethod

Source Link

Usage

From source file:cm.aptoide.pt.webservices.login.Login.java

private void drawLoginForm() {
    setContentView(R.layout.form_login);
    username_box = (EditText) findViewById(R.id.username);
    password_box = (EditText) findViewById(R.id.password);
    checkShowPass = (CheckBox) findViewById(R.id.show_login_passwd);
    checkShowPass.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                password_box.setTransformationMethod(null);
            } else {
                password_box.setTransformationMethod(new PasswordTransformationMethod());
            }/*w  w w  .j ava2s  .  c  om*/
        }
    });
    checkShowPass.setEnabled(true);

    createUser = (Button) findViewById(R.id.new_to_aptoide);
    SpannableString newUserString = new SpannableString(getString(R.string.new_to_aptoide));
    newUserString.setSpan(new UnderlineSpan(), 0, newUserString.length(), 0);
    createUser.setText(newUserString);

    forgot_password = (TextView) findViewById(R.id.forgot_password);
    SpannableString forgetString = new SpannableString(getString(R.string.forgot_passwd));
    forgetString.setSpan(new UnderlineSpan(), 0, forgetString.length(), 0);
    forgot_password.setText(forgetString);
    forgot_password.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent passwordRecovery = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://m.aptoide.com/account/password-recovery"));
            startActivity(passwordRecovery);
        }
    });
}

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  ww.  jav  a 2  s . c  om*/
        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:org.tomahawk.tomahawk_android.dialogs.ResolverConfigDialog.java

/**
 * Called when this {@link android.support.v4.app.DialogFragment} is being created
 *///from   www  . java2  s.  c  om
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getArguments() != null && getArguments().containsKey(TomahawkFragment.PREFERENCEID)) {
        String resolverId = getArguments().getString(TomahawkFragment.PREFERENCEID);
        mScriptResolver = (ScriptResolver) PipeLine.get().getResolver(resolverId);
    }

    EditText showKeyboardEditText = null;
    EditText lastEditText = null;
    if (mScriptResolver.getConfigUi() != null && mScriptResolver.getConfigUi().fields != null) {
        TextView headerTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview);
        headerTextView.setText(mScriptResolver.getDescription());
        for (ScriptResolverConfigUiField field : mScriptResolver.getConfigUi().fields) {
            Map<String, Object> config = mScriptResolver.getConfig();
            if (PROPERTY_CHECKED.equals(field.property)) {
                LinearLayout checkboxLayout = (LinearLayout) addScrollingViewToFrame(R.layout.config_checkbox);
                TextView textView = (TextView) checkboxLayout.findViewById(R.id.config_textview);
                textView.setText(field.name);
                ConfigCheckbox checkBox = (ConfigCheckbox) checkboxLayout.findViewById(R.id.config_checkbox);
                checkBox.mFieldName = field.name;
                mStringViews.add(checkBox);
                if (config.get(field.name) != null) {
                    checkBox.setChecked((Boolean) config.get(field.name));
                }
            } else if (PROPERTY_TEXT.equals(field.property)) {
                ConfigEdittext editText = (ConfigEdittext) addScrollingViewToFrame(R.layout.config_edittext);
                editText.mFieldName = field.name;
                editText.setHint(field.name);
                mStringViews.add(editText);
                if (config.get(field.name) != null) {
                    editText.setText((String) config.get(field.name));
                }
                if (VariousUtils.containsIgnoreCase(field.name, "password")) {
                    editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                    editText.setTransformationMethod(new PasswordTransformationMethod());
                }
                if (showKeyboardEditText == null) {
                    showKeyboardEditText = editText;
                }
                lastEditText = editText;
            } else if (PROPERTY_VALUE.equals(field.property)) {
                LinearLayout numberpickerLayout = (LinearLayout) addScrollingViewToFrame(
                        R.layout.config_numberpicker);
                TextView textView = (TextView) numberpickerLayout.findViewById(R.id.config_textview);
                textView.setText(field.name);
                ConfigNumberEdittext editText = (ConfigNumberEdittext) numberpickerLayout
                        .findViewById(R.id.config_edittext);
                editText.mFieldName = field.name;
                editText.setHint(field.name);
                mStringViews.add(editText);
                if (config.get(field.name) != null) {
                    editText.setText(String.valueOf(config.get(field.name)));
                }
                if (showKeyboardEditText == null) {
                    showKeyboardEditText = editText;
                }
                lastEditText = editText;
            }
        }
    } else {
        hideNegativeButton();
    }
    if (mScriptResolver.getScriptAccount().isManuallyInstalled()) {
        showRemoveButton();
    }
    if (lastEditText != null) {
        lastEditText.setOnEditorActionListener(mOnKeyboardEnterListener);
    }
    if (showKeyboardEditText != null) {
        ViewUtils.showSoftKeyboard(showKeyboardEditText);
    }
    setDialogTitle(mScriptResolver.getName());
    if (!mScriptResolver.isConfigTestable()) {
        setConnectImageViewClickable();
    }

    setStatus(mScriptResolver);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(getDialogView());
    return builder.create();
}

From source file:pt.up.mobile.authenticator.AuthenticatorActivity.java

/**
 * {@inheritDoc}//from  w  w w  . j a  va 2s  . c  om
 */
@Override
public void onCreate(Bundle icicle) {

    Log.i(TAG, "onCreate(" + icicle + ")");
    super.onCreate(icicle);
    setContentView(R.layout.login);
    mMessage = (TextView) findViewById(R.id.message);
    mUsernameEdit = (EditText) findViewById(R.id.login_username);
    mPasswordEdit = (EditText) findViewById(R.id.login_pass);
    mAccountManager = AccountManager.get(this);
    Log.i(TAG, "loading data from Intent");
    final Intent intent = getIntent();
    mUsername = intent.getStringExtra(PARAM_USERNAME);
    mRequestNewAccount = mUsername == null;
    mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false);
    if (mConfirmCredentials) {
        mUsernameEdit.setKeyListener(null); // disable username editing
        mPasswordEdit.requestFocus();
    }
    Log.i(TAG, "    request new: " + mRequestNewAccount);

    final CheckBox showPassword = (CheckBox) findViewById(R.id.show_password);
    showPassword.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            final int selection = mPasswordEdit.getSelectionStart();
            if (isChecked) {
                mPasswordEdit.setTransformationMethod(null);
            } else {
                mPasswordEdit.setTransformationMethod(new PasswordTransformationMethod());
            }
            mPasswordEdit.setSelection(selection);
        }
    });
    if (!TextUtils.isEmpty(mUsername))
        mUsernameEdit.setText(mUsername);
    mMessage.setText(R.string.login_activity_newaccount_text);
}

From source file:com.ubuntuone.android.files.fragment.SignUpFragment.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.password_toggle) {
        if (passwordVisibleCheckBox.isChecked()) {
            passwordEditText.setTransformationMethod(null);
        } else {//from ww w . j  a  v a 2 s  .  c o  m
            passwordEditText.setTransformationMethod(new PasswordTransformationMethod());
        }
        passwordEditText.setSelection(passwordEditText.getText().length());
    }
}

From source file:com.iiordanov.bVNC.dialogs.GetTextFragment.java

private void hideText(EditText textBox) {
    textBox.setTransformationMethod(new PasswordTransformationMethod());
}

From source file:org.runbuddy.tomahawk.dialogs.ResolverConfigDialog.java

/**
 * Called when this {@link android.support.v4.app.DialogFragment} is being created
 *//*from w w  w.ja  va2  s .  com*/
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getArguments() != null && getArguments().containsKey(TomahawkFragment.PREFERENCEID)) {
        String resolverId = getArguments().getString(TomahawkFragment.PREFERENCEID);
        mScriptResolver = PipeLine.get().getResolver(resolverId);
    }

    EditText showKeyboardEditText = null;
    EditText lastEditText = null;
    if (mScriptResolver.getConfigUi() != null) {
        TextView headerTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview);
        headerTextView.setText(mScriptResolver.getDescription());
        for (ScriptResolverConfigUiField field : mScriptResolver.getConfigUi()) {
            Map<String, Object> config = mScriptResolver.getConfig();
            if (ScriptResolverConfigUiField.TYPE_TEXTVIEW.equals(field.type)) {
                TextView textView = (TextView) addScrollingViewToFrame(R.layout.config_textview);
                if (field.text.startsWith("<html>")) {
                    textView.setText(Html.fromHtml(field.text));
                    textView.setMovementMethod(LinkMovementMethod.getInstance());
                } else {
                    textView.setText(field.text);
                }
            } else if (ScriptResolverConfigUiField.TYPE_CHECKBOX.equals(field.type)) {
                LinearLayout checkboxLayout = (LinearLayout) addScrollingViewToFrame(R.layout.config_checkbox);
                TextView textView = (TextView) checkboxLayout.findViewById(R.id.config_textview);
                textView.setText(field.label);
                ConfigCheckbox checkBox = (ConfigCheckbox) checkboxLayout.findViewById(R.id.config_checkbox);
                checkBox.mConfigFieldId = field.id;
                mConfigFieldViews.add(checkBox);
                if (config.get(field.id) != null) {
                    checkBox.setChecked((Boolean) config.get(field.id));
                } else {
                    checkBox.setChecked(Boolean.valueOf(field.defaultValue));
                }
            } else if (ScriptResolverConfigUiField.TYPE_TEXTFIELD.equals(field.type)) {
                ConfigEdittext editText = (ConfigEdittext) addScrollingViewToFrame(R.layout.config_edittext);
                editText.mConfigFieldId = field.id;
                editText.setHint(field.label);
                mConfigFieldViews.add(editText);
                if (config.get(field.id) != null) {
                    editText.setText((String) config.get(field.id));
                } else {
                    editText.setText(field.defaultValue);
                }
                if (field.isPassword) {
                    editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
                    editText.setTransformationMethod(new PasswordTransformationMethod());
                }
                if (showKeyboardEditText == null) {
                    showKeyboardEditText = editText;
                }
                lastEditText = editText;
            } else if (ScriptResolverConfigUiField.TYPE_DROPDOWN.equals(field.type)) {
                LinearLayout numberpickerLayout = (LinearLayout) addScrollingViewToFrame(
                        R.layout.config_dropdown);
                TextView textView = (TextView) numberpickerLayout.findViewById(R.id.config_textview);
                textView.setText(field.label);
                ConfigDropDown dropDown = (ConfigDropDown) numberpickerLayout
                        .findViewById(R.id.config_dropdown);
                dropDown.mConfigFieldId = field.id;
                mConfigFieldViews.add(dropDown);
                List<CharSequence> list = new ArrayList<>();
                for (String item : field.items) {
                    list.add(item);
                }
                ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(TomahawkApp.getContext(),
                        R.layout.spinner_textview, list);
                adapter.setDropDownViewResource(R.layout.spinner_dropdown_textview);
                dropDown.setAdapter(adapter);
                if (config.get(field.id) != null) {
                    dropDown.setSelection(((Double) config.get(field.id)).intValue());
                } else {
                    dropDown.setSelection(Integer.valueOf(field.defaultValue));
                }
            }
        }
    }
    if (mScriptResolver.getScriptAccount().isManuallyInstalled()) {
        showRemoveButton(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RemovePluginConfigDialog dialog = new RemovePluginConfigDialog();
                Bundle args = new Bundle();
                args.putString(TomahawkFragment.PREFERENCEID, mScriptResolver.getId());
                dialog.setArguments(args);
                dialog.show(getFragmentManager(), null);
                dismiss();
            }
        });
    }
    if (lastEditText != null) {
        lastEditText.setOnEditorActionListener(mOnKeyboardEnterListener);
    }
    if (showKeyboardEditText != null) {
        ViewUtils.showSoftKeyboard(showKeyboardEditText);
    }
    setDialogTitle(mScriptResolver.getName());

    showEnableButton(mEnableButtonListener);
    onResolverStateUpdated(mScriptResolver);

    hideNegativeButton();

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(getDialogView());
    return builder.create();
}

From source file:com.mediaexplorer.remote.MexRemoteActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from  www.  j  a va2  s.  co  m

    this.setTitle(R.string.app_name);
    dbg = "MexWebremote";

    text_view = (TextView) findViewById(R.id.text);

    web_view = (WebView) findViewById(R.id.link_view);
    web_view.getSettings().setJavaScriptEnabled(true);/*
                                                      /* Future: setOverScrollMode is API level >8
                                                      * web_view.setOverScrollMode (OVER_SCROLL_NEVER);
                                                      */

    web_view.setBackgroundColor(0);

    web_view.setWebViewClient(new WebViewClient() {
        /* for some reason we only get critical errors so an auth error
         * is not handled here which is why there is some crack that test
         * the connection with a special httpclient
         */
        @Override
        public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler,
                final String host, final String realm) {
            String[] userpass = new String[2];

            userpass = view.getHttpAuthUsernamePassword(host, realm);

            HttpResponse response = null;
            HttpGet httpget;
            DefaultHttpClient httpclient;
            String target_host;
            int target_port;

            target_host = MexRemoteActivity.this.target_host;
            target_port = MexRemoteActivity.this.target_port;

            /* We may get null from getHttpAuthUsernamePassword which will
             * break the setCredentials so junk used instead to keep
             * it happy.
             */

            Log.d(dbg, "using the set httpauth, testing auth using client");
            try {
                if (userpass == null) {
                    userpass = new String[2];
                    userpass[0] = "none";
                    userpass[1] = "none";
                }
            } catch (Exception e) {
                userpass = new String[2];
                userpass[0] = "none";
                userpass[1] = "none";
            }

            /* Log.d ("debug",
             *  "trying: GET http://"+userpass[0]+":"+userpass[1]+"@"+target_host+":"+target_port+"/");
             */
            /* We're going to test the authentication credentials that we
             * have before using them so that we can act on the response.
             */

            httpclient = new DefaultHttpClient();

            httpget = new HttpGet("http://" + target_host + ":" + target_port + "/");

            httpclient.getCredentialsProvider().setCredentials(new AuthScope(target_host, target_port),
                    new UsernamePasswordCredentials(userpass[0], userpass[1]));

            try {
                response = httpclient.execute(httpget);
            } catch (IOException e) {
                Log.d(dbg, "Problem executing the http get");
                e.printStackTrace();
            }

            Log.d(dbg, "HTTP reponse:" + Integer.toString(response.getStatusLine().getStatusCode()));
            if (response.getStatusLine().getStatusCode() == 401) {
                /* We got Authentication failed (401) so ask user for u/p */

                /* login dialog box */
                final AlertDialog.Builder logindialog;
                final EditText user;
                final EditText pass;

                LinearLayout layout;
                LayoutParams params;

                TextView label_username;
                TextView label_password;

                logindialog = new AlertDialog.Builder(MexRemoteActivity.this);

                logindialog.setTitle("Mex Webremote login");

                user = new EditText(MexRemoteActivity.this);
                pass = new EditText(MexRemoteActivity.this);

                layout = new LinearLayout(MexRemoteActivity.this);

                pass.setTransformationMethod(new PasswordTransformationMethod());

                layout.setOrientation(LinearLayout.VERTICAL);

                params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

                layout.setLayoutParams(params);
                user.setLayoutParams(params);
                pass.setLayoutParams(params);

                label_username = new TextView(MexRemoteActivity.this);
                label_password = new TextView(MexRemoteActivity.this);

                label_username.setText("Username:");
                label_password.setText("Password:");

                layout.addView(label_username);
                layout.addView(user);
                layout.addView(label_password);
                layout.addView(pass);
                logindialog.setView(layout);

                logindialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.cancel();
                    }
                });

                logindialog.setPositiveButton("Login", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String uvalue = user.getText().toString().trim();
                        String pvalue = pass.getText().toString().trim();
                        view.setHttpAuthUsernamePassword(host, realm, uvalue, pvalue);

                        handler.proceed(uvalue, pvalue);
                    }
                });
                logindialog.show();
                /* End login dialog box */
            } else /* We didn't get a 401 */
            {
                handler.proceed(userpass[0], userpass[1]);
            }
        } /* End onReceivedHttpAuthRequest */
    }); /* End Override */

    /* Run mdns to check for service in a "runnable" (async) */
    handler.post(new Runnable() {
        public void run() {
            startMdns();
        }
    });

    dialog = ProgressDialog.show(MexRemoteActivity.this, "", "Searching...", true);

    /* Let's put something in the webview while we're waiting */
    String summary = "<html><head><style>body { background-color: #000000; color: #ffffff; }></style></head><body><p>Searching for the media explorer webservice</p><p>More infomation on <a href=\"http://media-explorer.github.com\" >Media Explorer's home page</a></p></body></html>";
    web_view.loadData(summary, "text/html", "utf-8");

}

From source file:com.xirvik.transdroid.preferences.PreferencesXirvikServer.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // For which server?
    serverPostfix = getIntent().getStringExtra(PREFERENCES_XSERVER_KEY);
    // Create the preferences screen here: this takes care of saving/loading, but also contains the
    // ListView adapter, etc.
    setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    nameValue = prefs.getString(Preferences.KEY_PREF_XNAME + serverPostfix, null);
    typeValue = prefs.getString(Preferences.KEY_PREF_XTYPE + serverPostfix, null);
    serverValue = prefs.getString(Preferences.KEY_PREF_XSERVER + serverPostfix, null);
    folderValue = prefs.getString(Preferences.KEY_PREF_XFOLDER + serverPostfix, null);
    userValue = prefs.getString(Preferences.KEY_PREF_XUSER + serverPostfix, null);
    passValue = prefs.getString(Preferences.KEY_PREF_XPASS + serverPostfix, null);

    // Create preference objects
    getPreferenceScreen().setTitle(R.string.xirvik_pref_title);
    // Name/*from   w w w.  j a  v  a2 s  .c  o m*/
    name = new TransdroidEditTextPreference(this);
    name.setTitle(R.string.pref_name);
    name.setKey(Preferences.KEY_PREF_XNAME + serverPostfix);
    name.getEditText().setSingleLine();
    name.setDialogTitle(R.string.pref_name);
    name.setOnPreferenceChangeListener(updateHandler);
    getPreferenceScreen().addItemFromInflater(name);
    // Type
    type = new TransdroidListPreference(this);
    type.setTitle(R.string.xirvik_pref_type);
    type.setKey(Preferences.KEY_PREF_XTYPE + serverPostfix);
    type.setEntries(R.array.pref_xirvik_types);
    type.setEntryValues(R.array.pref_xirvik_values);
    type.setDialogTitle(R.string.xirvik_pref_type);
    type.setOnPreferenceChangeListener(updateHandler);
    getPreferenceScreen().addItemFromInflater(type);
    // Server
    server = new TransdroidEditTextPreference(this);
    server.setTitle(R.string.xirvik_pref_server);
    server.setKey(Preferences.KEY_PREF_XSERVER + serverPostfix);
    server.getEditText().setSingleLine();
    server.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    server.setDialogTitle(R.string.xirvik_pref_server);
    server.setOnPreferenceChangeListener(updateHandler);
    getPreferenceScreen().addItemFromInflater(server);
    // Folder
    folder = new TransdroidEditTextPreference(this);
    folder.setTitle(R.string.xirvik_pref_folder);
    folder.setKey(Preferences.KEY_PREF_XFOLDER + serverPostfix);
    folder.setEnabled(false);
    folder.setSummary(R.string.xirvik_pref_setautomatically);
    getPreferenceScreen().addItemFromInflater(folder);
    // User
    user = new TransdroidEditTextPreference(this);
    user.setTitle(R.string.pref_user);
    user.setKey(Preferences.KEY_PREF_XUSER + serverPostfix);
    user.getEditText().setSingleLine();
    user.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_FILTER);
    user.setDialogTitle(R.string.pref_user);
    user.setOnPreferenceChangeListener(updateHandler);
    getPreferenceScreen().addItemFromInflater(user);
    // Pass
    pass = new TransdroidEditTextPreference(this);
    pass.setTitle(R.string.pref_pass);
    pass.setKey(Preferences.KEY_PREF_XPASS + serverPostfix);
    pass.getEditText().setSingleLine();
    pass.getEditText().setInputType(EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
    pass.getEditText().setTransformationMethod(new PasswordTransformationMethod());
    pass.setDialogTitle(R.string.pref_pass);
    pass.setOnPreferenceChangeListener(updateHandler);
    getPreferenceScreen().addItemFromInflater(pass);

    // AlertFinished
    alarmFinished = new TransdroidCheckBoxPreference(this);
    alarmFinished.setDefaultValue(true);
    alarmFinished.setTitle(R.string.pref_alarmfinished);
    alarmFinished.setSummary(R.string.pref_alarmfinished_info);
    alarmFinished.setKey(Preferences.KEY_PREF_XALARMFINISHED + serverPostfix);
    alarmFinished.setOnPreferenceChangeListener(updateHandler);
    getPreferenceScreen().addItemFromInflater(alarmFinished);
    // AlertNew
    alarmNew = new TransdroidCheckBoxPreference(this);
    alarmNew.setTitle(R.string.pref_alarmnew);
    alarmNew.setSummary(R.string.pref_alarmnew_info);
    alarmNew.setKey(Preferences.KEY_PREF_XALARMNEW + serverPostfix);
    alarmNew.setOnPreferenceChangeListener(updateHandler);
    getPreferenceScreen().addItemFromInflater(alarmNew);

    updateDescriptionTexts();

}

From source file:com.googlecode.android_scripting.facade.ui.AlertDialogTask.java

@Override
public void onCreate() {
    super.onCreate();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    if (mTitle != null) {
        builder.setTitle(mTitle);//from   w w  w. j a va  2  s  . com
    }
    // Can't display both a message and items. We'll elect to show the items instead.
    if (mMessage != null && mItems.isEmpty()) {
        builder.setMessage(mMessage);
    }
    switch (mInputType) {
    // Add single choice menu items to dialog.
    case SINGLE_CHOICE:
        builder.setSingleChoiceItems(getItemsAsCharSequenceArray(), mSelectedItems.iterator().next(),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        mSelectedItems.clear();
                        mSelectedItems.add(item);
                    }
                });
        break;
    // Add multiple choice items to the dialog.
    case MULTI_CHOICE:
        boolean[] selectedItems = new boolean[mItems.size()];
        for (int i : mSelectedItems) {
            selectedItems[i] = true;
        }
        builder.setMultiChoiceItems(getItemsAsCharSequenceArray(), selectedItems,
                new DialogInterface.OnMultiChoiceClickListener() {
                    public void onClick(DialogInterface dialog, int item, boolean isChecked) {
                        if (isChecked) {
                            mSelectedItems.add(item);
                        } else {
                            mSelectedItems.remove(item);
                        }
                    }
                });
        break;
    // Add standard, menu-like, items to dialog.
    case MENU:
        builder.setItems(getItemsAsCharSequenceArray(), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                Map<String, Integer> result = new HashMap<String, Integer>();
                result.put("item", item);
                dismissDialog();
                setResult(result);
            }
        });
        break;
    case PLAIN_TEXT:
        mEditText = new EditText(getActivity());
        if (mDefaultText != null) {
            mEditText.setText(mDefaultText);
        }
        mEditText.setInputType(mEditInputType);
        builder.setView(mEditText);
        break;
    case PASSWORD:
        mEditText = new EditText(getActivity());
        mEditText.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
        mEditText.setTransformationMethod(new PasswordTransformationMethod());
        builder.setView(mEditText);
        break;
    default:
        // No input type specified.
    }
    configureButtons(builder, getActivity());
    addOnCancelListener(builder, getActivity());
    mDialog = builder.show();
    mShowLatch.countDown();
}