Beispiel #1
0
  private void initView() {
    type = (RadioGroup) findViewById(R.id.rg_questiontype);
    topic = (TextInputLayout) findViewById(R.id.questiontopic);
    option_a = (TextInputLayout) findViewById(R.id.option_a);
    option_b = (TextInputLayout) findViewById(R.id.option_b);
    option_c = (TextInputLayout) findViewById(R.id.option_c);
    option_d = (TextInputLayout) findViewById(R.id.option_d);
    submit = (AppCompatButton) findViewById(R.id.submit);
    //        choice = (AppCompatRadioButton) findViewById(R.id.type_choice);
    //        judge = (AppCompatRadioButton) findViewById(R.id.type_judgment);
    hint = (AppCompatTextView) findViewById(R.id.questionimage_hint);
    progressBar = (CircularProgressBar) findViewById(R.id.cpb);
    upload = (AppCompatTextView) findViewById(R.id.upload);

    image = (ImageButton) findViewById(R.id.questionimage);
    type.setOnCheckedChangeListener(this);
    image.setOnClickListener(this);
    image.setOnLongClickListener(this);
    submit.setOnClickListener(this);
    topic.getEditText().setOnFocusChangeListener(this);
    option_a.getEditText().setOnFocusChangeListener(this);
    option_b.getEditText().setOnFocusChangeListener(this);
    option_c.getEditText().setOnFocusChangeListener(this);
    option_d.getEditText().setOnFocusChangeListener(this);

    topic.setHint(getString(R.string.question_titlehint));
    option_a.setHint(getString(R.string.result_right));
    option_b.setHint(getString(R.string.result_false));
    option_c.setHint(getString(R.string.result_false));
    option_d.setHint(getString(R.string.result_false));
  }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.third_activity);

    btn = (Button) findViewById(R.id.btn);

    final TextInputLayout usernameWrapper = (TextInputLayout) findViewById(R.id.usernameWrapper);
    final TextInputLayout passwordWrapper = (TextInputLayout) findViewById(R.id.passwordWrapper);

    usernameWrapper.setHint("Username");
    passwordWrapper.setHint("Password");

    btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            hideKeyboard();
            // 获取到输入输入框里的内容
            String username = usernameWrapper.getEditText().getText().toString();
            String password = usernameWrapper.getEditText().getText().toString();

            if (!validateEmail(username)) {
              usernameWrapper.setError("Not a valid email address!");
            } else if (!validatePassword(password)) {
              passwordWrapper.setError("Not a valid password!");
            } else {
              usernameWrapper.setErrorEnabled(false);
              passwordWrapper.setErrorEnabled(false);
              doLogin();
            }
          }
        });
  }
Beispiel #3
0
 public void initEditText() {
   textInputLayoutusername = (TextInputLayout) findViewById(R.id.tiusername);
   textInputLayoutpasswords = (TextInputLayout) findViewById(R.id.tiuserpasswords);
   textInputLayoutport = (TextInputLayout) findViewById(R.id.tiuserport);
   textInputLayoutdir = (TextInputLayout) findViewById(R.id.tidir);
   textInputLayoutpasswords.setHint(getString(R.string.passwordhint));
   textInputLayoutusername.setHint(getString(R.string.usernamehint));
   textInputLayoutport.setHint(getString(R.string.porthint));
   textInputLayoutdir.setHint(getString(R.string.pathhint));
 }
Beispiel #4
0
  void init() {

    ed_id = (EditText) findViewById(R.id.editText_ID);
    ed_pw = (EditText) findViewById(R.id.editText_PW);
    Til_id = (TextInputLayout) findViewById(R.id.Til_id);
    Til_id.setHint("아이디");
    Til_pw = (TextInputLayout) findViewById(R.id.Til_pw);
    Til_pw.setHint("패스워드");
    ed_id.clearFocus();
    rel = (RelativeLayout) findViewById(R.id.MainActivityRelativeLayout);
    rel.requestFocus();
  }
  public void updateType(Amenity amenity) {
    poiTypeEditText.setText(amenity.getSubType());
    poiTypeTextInputLayout.setHint(amenity.getType().getTranslation());
    setAdapterForPoiTypeEditText();
    poiTypeEditText.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(final View v, MotionEvent event) {
            final EditText editText = (EditText) v;
            final int DRAWABLE_RIGHT = 2;
            if (event.getAction() == MotionEvent.ACTION_UP) {
              if (event.getX()
                  >= (editText.getRight()
                      - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
                      - editText.getPaddingRight())) {
                if (editPoiData.amenity.getType() != null) {
                  DialogFragment dialogFragment =
                      PoiSubTypeDialogFragment.createInstance(editPoiData.amenity);
                  dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment");
                }

                return true;
              }
            }
            return false;
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_text_input_layout);

    final TextInputLayout textInputLayout = (TextInputLayout) findViewById(R.id.my_input_layout);

    EditText editText = textInputLayout.getEditText();
    textInputLayout.setHint("Password");

    editText.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > 4) {
              textInputLayout.setError("Password error");
              textInputLayout.setErrorEnabled(true);
            } else {
              textInputLayout.setErrorEnabled(false);
            }
          }

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_editar_user);
    final Vehiculo vehiculo = (Vehiculo) getIntent().getExtras().getSerializable("vehiculo");
    final User conductor = (User) getIntent().getExtras().getSerializable("conductor");
    final User sesion = (User) getIntent().getExtras().getSerializable("sesion");
    Toolbar toolbar = (Toolbar) findViewById(R.id.mitoolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(
        ContextCompat.getDrawable(this, R.drawable.abc_ic_ab_back_mtrl_am_alpha));
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(EditarUserActivity.this, DetalleUserActivity.class);
            intent.putExtra("sesion", sesion);
            intent.putExtra("vehiculo", vehiculo);
            intent.putExtra("conductor", conductor);
            startActivity(intent);
          }
        });
    email = (TextInputLayout) findViewById(R.id.TIL_EditarUser_Email);
    nombre = (TextInputLayout) findViewById(R.id.TIL_EditarUser_Nombre);
    apellido = (TextInputLayout) findViewById(R.id.TIL_EditarUser_Apellido);
    contraseña1 = (TextInputLayout) findViewById(R.id.TIL_EditarUser_Contraseña);
    contraseña2 = (TextInputLayout) findViewById(R.id.TIL_EditarUser_Contraseña2);
    dueño = (CheckBox) findViewById(R.id.CB_EditarUser_Dueño);
    textView = (TextView) findViewById(R.id.TV_EditarUser_Dueño);
    imagen = (ImageView) findViewById(R.id.IV_EditarUser_User);

    email.setHint(conductor.getEmail());
    nombre.setHint(conductor.getNombre());
    apellido.setHint(conductor.getApellido());
    dueño.setChecked(conductor.isDueño());
    progressBar = (ProgressBar) findViewById(R.id.PB_EditarUser_Progressbar);
    if (!sesion.isEnrolador()) {
      dueño.setVisibility(View.GONE);
      textView.setVisibility(View.GONE);
    }
  }
 @SuppressLint("InflateParams")
 public EditTextDialogBuilder(Context context, String text, String hint) {
   super(context);
   View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_edittext_builder, null);
   setView(view);
   mTextInputLayout = (TextInputLayout) view;
   mEditText = (EditText) view.findViewById(R.id.edit_text);
   mEditText.setText(text);
   mEditText.setSelection(mEditText.getText().length());
   mEditText.setOnEditorActionListener(this);
   mTextInputLayout.setHint(hint);
 }
Beispiel #9
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_playlist, container);

    mListView = (ListView) view.findViewById(android.R.id.list);
    mSaveButton = (Button) view.findViewById(R.id.dialog_playlist_save);
    mEmptyView = (TextView) view.findViewById(android.R.id.empty);
    TextInputLayout mLayout = (TextInputLayout) view.findViewById(R.id.dialog_playlist_name);
    mLayout.setHint(getString(R.string.playlist_name_hint));
    mEditText = mLayout.getEditText();
    mListView.setOnItemClickListener(this);
    mSaveButton.setOnClickListener(this);

    mEditText.setOnEditorActionListener(this);
    mListView.setEmptyView(mEmptyView);
    mListView.setAdapter(mAdapter);
    return view;
  }
 @NonNull
 @Override
 public Dialog onCreateDialog(Bundle savedInstanceState) {
   AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
   LayoutInflater inflater = getActivity().getLayoutInflater();
   final String phoneNumber = ApplicationHelper.getPhone(getActivity());
   View view = (View) inflater.inflate(R.layout.dialog, null);
   textInputLayout = (TextInputLayout) view.findViewById(R.id.inputLayout);
   textInputLayout.setHint("Ваш номер");
   phone = (TextView) view.findViewById(R.id.phone);
   phone.setText(phoneNumber);
   builder
       .setTitle("Отправить заказ")
       .setView(view)
       .setPositiveButton(
           "Отправить",
           new DialogInterface.OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int which) {}
           });
   return builder.create();
 }
  static void showDialog(
      Context context, @StringRes int hint, @NonNull final OnTextInputListener callback) {
    final View promptsView = LayoutInflater.from(context).inflate(R.layout.dialog_input_text, null);

    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    alertDialogBuilder.setView(promptsView);

    final TextInputLayout textInputLayout =
        (TextInputLayout) promptsView.findViewById(R.id.input_text_layout);
    textInputLayout.setHint(context.getString(hint));

    final EditText userInputEditText = (EditText) promptsView.findViewById(R.id.input_text);

    final DialogInterface.OnClickListener clickListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            switch (which) {
              case Dialog.BUTTON_POSITIVE:
                callback.onTextInput(userInputEditText.getText().toString());
                // fallthrough
              case Dialog.BUTTON_NEGATIVE:
                dialog.dismiss();
                break;
            }
          }
        };

    alertDialogBuilder
        .setPositiveButton(R.string.input_text_dialog_ok, clickListener)
        .setNegativeButton(R.string.input_text_dialog_cancel, clickListener);

    final AlertDialog alertDialog = alertDialogBuilder.create();

    alertDialog.show();
  }
Beispiel #12
0
 private void resetAutoCompleteHint() {
   mChapterSpinnerTextInputLayout.setHint(getString(R.string.home_gdg));
   mChapterSpinnerTextInputLayout.setError(null);
 }
Beispiel #13
0
 private void updateAutoCompleteHint(Chapter selectedChapter) {
   mChapterSpinnerTextInputLayout.setHint(
       getString(R.string.home_gdg_with_city, selectedChapter.toString()));
   mChapterSpinnerTextInputLayout.setError(null);
 }
Beispiel #14
0
 public void setHint(String hint) {
   tilTitle.setHint(hint);
 }
  public void newEditText(final String propertyName) {

    int top =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
    LayoutParams linearParams =
        new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setPadding(0, top, 0, 0);
    linearLayout.setLayoutParams(linearParams);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    ll.addView(linearLayout);

    TextInputLayout v = new TextInputLayout(context);
    LayoutParams textInputParams =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    v.setLayoutParams(textInputParams);

    linearLayout.addView(v);

    final EditText editText = new EditText(context);

    int width =
        (int)
            TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics());
    LayoutParams editTextParams = new LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT);

    editText.setLayoutParams(editTextParams);
    editText.setInputType(InputType.TYPE_CLASS_TEXT);

    v.setHint("Message");

    v.addView(editText);

    //        int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200,
    // getResources().getDisplayMetrics());
    //        LayoutParams editTextParams = new LayoutParams(width,
    // ViewGroup.LayoutParams.WRAP_CONTENT);
    //        final EditText editText = new EditText(context);
    //        editText.setId(View.generateViewId());
    //        editText.setInputType(InputType.TYPE_CLASS_TEXT);
    //        editText.setHint("Your Text");
    //
    //        editText.setLayoutParams(editTextParams);
    //
    //        linearLayout.addView(editText);

    ImageButton button = new ImageButton(context);
    button.setImageResource(R.drawable.send);
    LayoutParams buttonParams = new LayoutParams(100, ViewGroup.LayoutParams.WRAP_CONTENT);
    button.setLayoutParams(buttonParams);

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            try {
              thing.setProperty(propertyName, editText.getText().toString());
              thing.updateSubscribedProperties(500);
            } catch (Exception e) {
              e.printStackTrace();
            }
            editText.clearFocus();
            editText.setText("");
          }
        });
    linearLayout.addView(button);
  }
  public void init(final Context context, AttributeSet attrs, int defStyleAttr) {
    FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    textInputLayout = new TextInputLayout(context);
    textInputLayout.setLayoutParams(params);
    String hint = attrs.getAttributeValue(ANDROID_NS, "hint");
    if (hint != null) {
      textInputLayout.setHint(hint);
    }
    editText = new PermissionedEditText(context);
    editText.setSelectionListener(selectionListener);
    editText.setId(View.generateViewId());
    editText.setLayoutParams(params);
    int inputType = attrs.getAttributeIntValue(ANDROID_NS, "inputType", EditorInfo.TYPE_NULL);
    if (inputType != EditorInfo.TYPE_NULL) {
      editText.setInputType(inputType);
    }

    textInputLayout.addView(editText, params);
    addView(textInputLayout);

    overlay = new FrameLayout(context);
    overlay.setLayoutParams(
        new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    //        overlay.setBackgroundColor(Color.BLACK);
    overlay.setBackgroundResource(R.drawable.permission_overlay_bg);
    overlay.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              Toast.makeText(
                      getContext(), "This device does not have permission to view this field", 0)
                  .show();
            }
            return true;
          }
        });
    overlay.setVisibility(GONE);
    TextView overlayLabel = new TextView(context);
    overlayLabel.setTextSize(24);
    overlayLabel.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
    overlayLabel.setText(hint + " Unavailable");

    overlay.addView(overlayLabel);
    addView(overlay);

    actionButton = new ImageView(context);
    IconDrawable drawable = new IconDrawable(context, MaterialIcons.md_check);
    drawable.color(Color.GREEN);
    actionButton.setImageDrawable(drawable);
    actionButton.setLayoutParams(new FrameLayout.LayoutParams(100, 100, Gravity.RIGHT));
    actionButton.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                {
                  ImageView view = (ImageView) v;
                  view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
                  view.invalidate();
                  break;
                }
              case MotionEvent.ACTION_UP:
                if (permissionedTextListener != null) {
                  int aId = 0;
                  if (mPrimaryAction != null) {
                    aId = mPrimaryAction.id;
                  }
                  permissionedTextListener.onAction(aId, PermissionedTextLayout.this);
                }
              case MotionEvent.ACTION_CANCEL:
                {
                  ImageView view = (ImageView) v;
                  view.getDrawable().clearColorFilter();
                  view.invalidate();
                  break;
                }
            }
            return true;
          }
        });
    actionButton.setVisibility(GONE);
    addView(actionButton);
  }