Class SimpleInputDialog

java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
All Implemented Interfaces:
android.content.ComponentCallbacks, android.content.DialogInterface.OnCancelListener, android.content.DialogInterface.OnDismissListener, android.view.View.OnCreateContextMenuListener, androidx.activity.result.ActivityResultCaller, androidx.lifecycle.HasDefaultViewModelProviderFactory, androidx.lifecycle.LifecycleOwner, androidx.lifecycle.ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner
Direct Known Subclasses:
SimpleEMailDialog

public class SimpleInputDialog extends CustomViewDialog<SimpleInputDialog>
An simple dialog with an input field. Supports suggestions, input validations and max length options. Results: TEXT String The entered text Created by eltos on 14.10.2015.
  • Field Details

  • Constructor Details

    • SimpleInputDialog

      public SimpleInputDialog()
  • Method Details

    • build

      public static SimpleInputDialog build()
    • hint

      public SimpleInputDialog hint(String hint)
      Sets the EditText's hint
      Parameters:
      hint - the hint as string
      Returns:
      this instance
    • hint

      public SimpleInputDialog hint(@StringRes int hintResourceId)
      Sets the EditText's hint
      Parameters:
      hintResourceId - the hint as android string resource
      Returns:
      this instance
    • text

      public SimpleInputDialog text(String text)
      Sets the EditText's initial text
      Parameters:
      text - initial text as string
      Returns:
      this instance
    • text

      public SimpleInputDialog text(@StringRes int textResourceId)
      Sets the EditText's initial text
      Parameters:
      textResourceId - initial text as android string resource
      Returns:
      this instance
    • inputType

      public SimpleInputDialog inputType(int inputType)
      Sets the input type The default is InputType.TYPE_CLASS_TEXT.
      Parameters:
      inputType - the InputType
      Returns:
      this instance
    • allowEmpty

      public SimpleInputDialog allowEmpty(boolean allow)
      Allow empty input. Default is to disable the positive button until text is entered.
      Parameters:
      allow - whether to allow empty input
      Returns:
      this instance
    • max

      public SimpleInputDialog max(int maxLength)
      Sets a max limit to the EditText.
      Parameters:
      maxLength - the maximum text length
      Returns:
      this instance
    • suggest

      public SimpleInputDialog suggest(android.content.Context context, int[] stringResourceIds)
      Provide an array of suggestions to be shown while the user is typing
      Parameters:
      context - a context to resolve the resource ids
      stringResourceIds - suggestion array as android string resources
      Returns:
      this instance
    • suggest

      public SimpleInputDialog suggest(String[] strings)
      Provide an array of suggestions to be shown while the user is typing
      Parameters:
      strings - suggestion string array
      Returns:
      this instance
    • onValidateInput

      @Nullable protected String onValidateInput(@Nullable String input)
    • getText

      @Nullable public String getText()
      Returns:
      the current text or null
    • isInputEmpty

      public boolean isInputEmpty()
    • openKeyboard

      public void openKeyboard()
      Helper for opening the soft keyboard
    • onCreateContentView

      public android.view.View onCreateContentView(android.os.Bundle savedInstanceState)
      Description copied from class: CustomViewDialog
      Inflate your custom view here.
      Specified by:
      onCreateContentView in class CustomViewDialog<SimpleInputDialog>
      Parameters:
      savedInstanceState - The last saved instance state of the Fragment, or null if this fragment is created for the first time.
      Returns:
      Return a new View to be displayed by the Fragment.
    • posEnabled

      protected boolean posEnabled()
    • onDialogShown

      protected void onDialogShown()
      Description copied from class: CustomViewDialog
      Overwrite this method to take action once the dialog is shown such as settings an input focus, showing the keyboard or setting the initial positiveButtonState
      Overrides:
      onDialogShown in class CustomViewDialog<SimpleInputDialog>
    • acceptsPositiveButtonPress

      protected boolean acceptsPositiveButtonPress()
      Description copied from class: CustomViewDialog
      Overwrite this method to catch positive button presses, e.g. if you need to verify input by the user Note: do not call CustomViewDialog.pressPositiveButton() here!
      Overrides:
      acceptsPositiveButtonPress in class CustomViewDialog<SimpleInputDialog>
      Returns:
      false to ignore the press, true to process normally
    • onResult

      public android.os.Bundle onResult(int which)
      Description copied from class: CustomViewDialog
      Overwrite this method to provide additional results from your custom view to be passed to the SimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
      Overrides:
      onResult in class CustomViewDialog<SimpleInputDialog>
      Parameters:
      which - see SimpleDialog.OnDialogResultListener
      Returns:
      the bundle to merge with the results or null
    • onSaveInstanceState

      public void onSaveInstanceState(android.os.Bundle outState)
      Overrides:
      onSaveInstanceState in class androidx.fragment.app.DialogFragment