Search in sources :

Example 16 with OnShowListener

use of android.content.DialogInterface.OnShowListener in project packages_apps_Contacts by AOKP.

the class GroupNameDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    final LayoutInflater layoutInflater = LayoutInflater.from(builder.getContext());
    final View view = layoutInflater.inflate(R.layout.group_name_dialog, null);
    final EditText editText = (EditText) view.findViewById(R.id.group_label);
    initializeGroupLabelEditText(editText);
    builder.setTitle(getTitleResourceId());
    builder.setView(view);
    editText.requestFocus();
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int whichButton) {
            onCompleted(editText.getText().toString().trim());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {
            updateOkButtonState(dialog, editText);
        }
    });
    editText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

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

        @Override
        public void afterTextChanged(Editable s) {
            updateOkButtonState(dialog, editText);
        }
    });
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) OnShowListener(android.content.DialogInterface.OnShowListener) LayoutInflater(android.view.LayoutInflater) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Example 17 with OnShowListener

use of android.content.DialogInterface.OnShowListener in project Android-DialogFragments by wada811.

the class AbstractDialogFragment method setOnShowListener.

protected void setOnShowListener(Dialog dialog) {
    useOnShowListener = true;
    dialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            bindShowListener();
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) OnShowListener(android.content.DialogInterface.OnShowListener)

Aggregations

DialogInterface (android.content.DialogInterface)17 OnShowListener (android.content.DialogInterface.OnShowListener)17 AlertDialog (android.app.AlertDialog)14 View (android.view.View)12 TextView (android.widget.TextView)9 OnCancelListener (android.content.DialogInterface.OnCancelListener)6 OnClickListener (android.content.DialogInterface.OnClickListener)5 DialogBuilder (de.schildbach.wallet.ui.DialogBuilder)5 EditText (android.widget.EditText)4 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)3 OnClickListener (android.view.View.OnClickListener)3 ViewGroup (android.view.ViewGroup)3 CheckBox (android.widget.CheckBox)3 SuppressLint (android.annotation.SuppressLint)2 TargetApi (android.annotation.TargetApi)2 Builder (android.app.AlertDialog.Builder)2 DatePickerDialog (android.app.DatePickerDialog)2 OnDateSetListener (android.app.DatePickerDialog.OnDateSetListener)2 Dialog (android.app.Dialog)2