android.widget.EditText#post ( )源码实例Demo

下面列出了android.widget.EditText#post ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dynamic-support   文件: DynamicInputUtils.java
/**
 * Show the soft input keyboard and focus it on the supplied {@link EditText}.
 *
 * @param editText The edit text to show the soft input.
 */
public static void showSoftInput(final @NonNull EditText editText) {
    editText.requestFocus();
    editText.post(new Runnable() {
        @Override
        public void run() {
            InputMethodManager inputMethodManager = (InputMethodManager)
                    editText.getContext().getSystemService(Service.INPUT_METHOD_SERVICE);
            if (inputMethodManager != null) {
                inputMethodManager.showSoftInput(editText, 0);
                editText.clearFocus();
                editText.requestFocus();
            }
        }
    });
}
 
源代码2 项目: FitbitAndroidSample   文件: MainActivity.java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent){
    super.onActivityResult(requestCode, resultCode, intent);
    
    if (requestCode == GET_PIN_REQUEST) {
    	
        if (resultCode == RESULT_OK) {
            Bundle extras = intent.getExtras();
            if(extras != null){
            	final String pin = extras.getString("PIN");
            	final EditText etPIN = (EditText) findViewById(R.id.etPIN);
            	
            	etPIN.post(new Runnable() {
		@Override
		public void run() {
			etPIN.setText(pin);
		}
	});
            }
        }
    }
}
 
public void testFilledBluetoothMacAddressFieldButtonClickShowsProgressDialog() throws Exception {
        //checkAndDismissBluetoothDialog();
        makeScreenshot("init");
        final EditText text = (EditText) getActivity().findViewById(R.id.input_text_bluetooth_address);

        final String macAddress = "00:11:22:33:44";

        text.post(new Runnable() {
            @Override
            public void run() {
                text.setText(macAddress);
            }
        });

        makeScreenshot("Item_filled");
        onView(withId(R.id.input_text_bluetooth_address)).perform(click());


//        onView(withId(R.id.spinner_bluetooth_addresses)).perform(click(pressImeActionButton()));
        onView(withId(R.id.btn_write_bluetooth_nfc)).perform(click());
        makeScreenshot("Showing_progressdialog");
        checkProgressDialogShowing();
        makeScreenshot("end");
    }
 
源代码4 项目: mollyim-android   文件: InputAwareLayout.java
public void showSoftkey(final EditText inputTarget) {
  postOnKeyboardOpen(new Runnable() {
    @Override public void run() {
      hideAttachedInput(true);
    }
  });
  inputTarget.post(new Runnable() {
    @Override public void run() {
      inputTarget.requestFocus();
      ServiceUtil.getInputMethodManager(inputTarget.getContext()).showSoftInput(inputTarget, 0);
    }
  });
}
 
源代码5 项目: AndroidUiKit   文件: EditTextDialog.java
@Override
public void bindView(View v) {
    mEditText = (EditText) v.findViewById(R.id.edit_text);
    mEditText.post(new Runnable() {
        @Override
        public void run() {
            InputMethodManager imm =
                    (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(mEditText, 0);
        }
    });
}
 
源代码6 项目: belvedere   文件: KeyboardHelper.java
static void showKeyboard(final EditText editText) {
    editText.post(new Runnable() {
        @Override
        public void run() {
            if(editText.requestFocus()) {
                InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                if(imm != null) {
                    imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
                }
            }
        }
    });
}
 
源代码7 项目: ChatRecyclerView   文件: InputDialog.java
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final EditText editText = (EditText) view.findViewById(R.id.mEtInput);
    view.findViewById(R.id.mBtnSend).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mAction.send(editText.getText().toString());
            dismiss();
        }
    });
    KeyboardVisibilityEvent.setEventListener(getActivity(),
            new KeyboardVisibilityEventListener() {
                @Override
                public void onVisibilityChanged(boolean isOpen) {
                    if (!isOpen) {
                        dismiss();
                    }
                }
            });
    editText.post(new Runnable() {
        @Override
        public void run() {
            UIUtil.showKeyboard(getContext(), editText);
        }
    });
}
 
源代码8 项目: ChatRecyclerView   文件: InputDialogFragment.java
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final EditText paramEditText = (EditText) view.findViewById(R.id.mEditText);
    paramEditText.requestFocus();
    paramEditText.post(new Runnable() {

        @Override
        public void run() {
            ((InputMethodManager) getActivity().getSystemService(Context
                    .INPUT_METHOD_SERVICE)).showSoftInput(paramEditText, 0);
        }
    });
}
 
源代码9 项目: BottomDialog   文件: EditTextDialog.java
@Override
public void bindView(View v) {
    mEditText = (EditText) v.findViewById(R.id.edit_text);
    mEditText.post(new Runnable() {
        @Override
        public void run() {
            InputMethodManager imm =
                    (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(mEditText, 0);
        }
    });
}
 
源代码10 项目: deltachat-android   文件: InputAwareLayout.java
public void showSoftkey(final EditText inputTarget) {
  postOnKeyboardOpen(() -> hideAttachedInput(true));
  inputTarget.post(() -> {
    inputTarget.requestFocus();
    ServiceUtil.getInputMethodManager(inputTarget.getContext()).showSoftInput(inputTarget, 0);
  });
}
 
源代码11 项目: Silence   文件: InputAwareLayout.java
public void showSoftkey(final EditText inputTarget) {
  postOnKeyboardOpen(new Runnable() {
    @Override public void run() {
      hideAttachedInput(true);
    }
  });
  inputTarget.post(new Runnable() {
    @Override public void run() {
      inputTarget.requestFocus();
      ServiceUtil.getInputMethodManager(inputTarget.getContext()).showSoftInput(inputTarget, 0);
    }
  });
}
 
源代码12 项目: actor-platform   文件: BaseAuthFragment.java
protected void focus(final EditText editText) {
    editText.post(new Runnable() {
        @Override
        public void run() {
            editText.requestFocus();
            editText.setSelection(editText.getText().length());
        }
    });
}
 
源代码13 项目: AndroidPlayground   文件: InputDialogFragment.java
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final EditText paramEditText = (EditText) view.findViewById(R.id.mEditText);
    paramEditText.requestFocus();
    paramEditText.post(new Runnable() {

        @Override
        public void run() {
            ((InputMethodManager) getActivity().getSystemService(Context
                    .INPUT_METHOD_SERVICE)).showSoftInput(paramEditText, 0);
        }
    });
}
 
public void testEmptyBluetoothFieldNotDisplayingAfterClick() {
    final EditText editText = (EditText) getActivity().findViewById(R.id.input_text_bluetooth_address);
    editText.post(new Runnable() {
        @Override
        public void run() {
            editText.setText(null);
        }
    });
    emptyFieldNotDisplayingToast(R.id.btn_write_bluetooth_nfc);
}
 
源代码15 项目: zhangshangwuda   文件: SmileyPickerUtility.java
public static void showKeyBoard(final EditText paramEditText) {
	paramEditText.requestFocus();
	paramEditText.post(new Runnable() {
		@Override
		public void run() {
			((InputMethodManager) MyApplication.getInstance()
					.getSystemService("input_method")).showSoftInput(
					paramEditText, 0);
		}
	});
}
 
源代码16 项目: u2020   文件: DebugView.java
private void showNewNetworkProxyDialog(final ProxyAdapter proxyAdapter) {
  final int originalSelection = networkProxyAddress.isSet() ? ProxyAdapter.PROXY : ProxyAdapter.NONE;

  View view = LayoutInflater.from(app).inflate(R.layout.debug_drawer_network_proxy, null);
  final EditText hostView = view.findViewById(R.id.debug_drawer_network_proxy_host);

  if(networkProxyAddress.isSet()) {
    String host = networkProxyAddress.get().getHostName();
    hostView.setText(host); // Set the current host.
    hostView.setSelection(0, host.length()); // Pre-select it for editing.

    // Show the keyboard. Post this to the next frame when the dialog has been attached.
    hostView.post(() -> Keyboards.showKeyboard(hostView));
  }

  new AlertDialog.Builder(getContext()) //
      .setTitle("Set Network Proxy")
      .setView(view)
      .setNegativeButton("Cancel", (dialog, i) -> {
        networkProxyView.setSelection(originalSelection);
        dialog.cancel();
      })
      .setPositiveButton("Use", (dialog, i) -> {
        String in = hostView.getText().toString();
        InetSocketAddress address = InetSocketAddressPreferenceAdapter.parse(in);
        if (address != null) {
          networkProxyAddress.set(address);
          // Force a restart to re-initialize the app with the new proxy.
          ProcessPhoenix.triggerRebirth(getContext());
        } else {
          networkProxyView.setSelection(originalSelection);
        }
      })
      .setOnCancelListener(dialogInterface -> networkProxyView.setSelection(originalSelection))
      .show();
}
 
源代码17 项目: mollyim-android   文件: SignalPinReminderDialog.java
public static void show(@NonNull Context context, @NonNull Launcher launcher, @NonNull Callback mainCallback) {
  if (!SignalStore.kbsValues().hasPin()) {
    throw new AssertionError("Must have a PIN!");
  }

  Log.i(TAG, "Showing PIN reminder dialog.");

  AlertDialog dialog = new AlertDialog.Builder(context, ThemeUtil.isDarkTheme(context) ? R.style.Theme_Signal_AlertDialog_Dark_Cornered_ColoredAccent : R.style.Theme_Signal_AlertDialog_Light_Cornered_ColoredAccent)
                                      .setView(R.layout.kbs_pin_reminder_view)
                                      .setCancelable(false)
                                      .setOnCancelListener(d -> RegistrationLockReminders.scheduleReminder(context, false))
                                      .create();

  WindowManager  windowManager = ServiceUtil.getWindowManager(context);
  Display        display       = windowManager.getDefaultDisplay();
  DisplayMetrics metrics       = new DisplayMetrics();
  display.getMetrics(metrics);

  dialog.show();
  dialog.getWindow().setLayout((int)(metrics.widthPixels * .80), ViewGroup.LayoutParams.WRAP_CONTENT);

  EditText pinEditText = (EditText) DialogCompat.requireViewById(dialog, R.id.pin);
  TextView pinStatus   = (TextView) DialogCompat.requireViewById(dialog, R.id.pin_status);
  TextView reminder    = (TextView) DialogCompat.requireViewById(dialog, R.id.reminder);
  View     skip        = DialogCompat.requireViewById(dialog, R.id.skip);
  View     submit      = DialogCompat.requireViewById(dialog, R.id.submit);

  SpannableString reminderText = new SpannableString(context.getString(R.string.KbsReminderDialog__to_help_you_memorize_your_pin));
  SpannableString forgotText   = new SpannableString(context.getString(R.string.KbsReminderDialog__forgot_pin));

  pinEditText.post(() -> {
    if (pinEditText.requestFocus()) {
      ServiceUtil.getInputMethodManager(pinEditText.getContext()).showSoftInput(pinEditText, 0);
    }
  });
  ViewCompat.setAutofillHints(pinEditText, HintConstants.AUTOFILL_HINT_PASSWORD);

  switch (SignalStore.pinValues().getKeyboardType()) {
    case NUMERIC:
      pinEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
      break;
    case ALPHA_NUMERIC:
      pinEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
      break;
  }

  ClickableSpan clickableSpan = new ClickableSpan() {
    @Override
    public void onClick(@NonNull View widget) {
      dialog.dismiss();
      launcher.launch(CreateKbsPinActivity.getIntentForPinChangeFromForgotPin(context), CreateKbsPinActivity.REQUEST_NEW_PIN);
    }
  };

  forgotText.setSpan(clickableSpan, 0, forgotText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

  reminder.setText(new SpannableStringBuilder(reminderText).append(" ").append(forgotText));
  reminder.setMovementMethod(LinkMovementMethod.getInstance());

  PinVerifier.Callback callback = getPinWatcherCallback(context, dialog, pinEditText, pinStatus, mainCallback);
  PinVerifier          verifier = new V2PinVerifier();

  skip.setOnClickListener(v -> {
    dialog.dismiss();
    mainCallback.onReminderDismissed(callback.hadWrongGuess());
  });

  submit.setEnabled(false);
  submit.setOnClickListener(v -> {
    Editable pinEditable = pinEditText.getText();

    verifier.verifyPin(pinEditable == null ? null : pinEditable.toString(), callback);
  });

  pinEditText.addTextChangedListener(new SimpleTextWatcher() {

    private final String localHash = Objects.requireNonNull(SignalStore.kbsValues().getLocalPinHash());

    @Override
    public void onTextChanged(String text) {
      if (text.length() >= KbsConstants.MINIMUM_PIN_LENGTH) {
        submit.setEnabled(true);

        if (PinHashing.verifyLocalPinHash(localHash, text)) {
          dialog.dismiss();
          mainCallback.onReminderCompleted(text, callback.hadWrongGuess());
        }
      } else {
        submit.setEnabled(false);
      }
    }
  });
}
 
源代码18 项目: ReadMark   文件: WaveLoadingViewHolder.java
private void initViews(){
    mContentView = LayoutInflater.from(mContext)
            .inflate(R.layout.item_wave_loading_view, mViewGroup, false);
    mWaveLoadingView = (WaveLoadingView) mContentView.findViewById(R.id.wave_loading_view);
    mWaveLoadingView.post(new Runnable() {
        @Override
        public void run() {
            mWaveLoadingView.setWaveColor(mBookshelf.getColor());
        }
    });
    mRedPicker = (SeekBar) mContentView.findViewById(R.id.red_picker);
    mGreenPicker = (SeekBar) mContentView.findViewById(R.id.green_picker);
    mBluePicker = (SeekBar) mContentView.findViewById(R.id.blue_picker);
    mAmpPicker = (SeekBar) mContentView.findViewById(R.id.amp_picker);
    mWavePicker = (SeekBar) mContentView.findViewById(R.id.wave_picker);
    mCurrentPage = (EditText) mContentView.findViewById(R.id.edit_current_page);
    mTotalPages = (TextView) mContentView.findViewById(R.id.text_total_page);
    mConfirmButton = (Button) mContentView.findViewById(R.id.button_confirm);
    //mCancelButton = (Button) mContentView.findViewById(R.id.button_cancel);


    mRedPicker.post(new Runnable() {
        @Override
        public void run() {
            mRedPicker.setProgress( (int)((mBookshelf.getRed() / 255.0f) * 100));
        }
    });
    mGreenPicker.post(new Runnable() {
        @Override
        public void run() {
            mGreenPicker.setProgress((int)((mBookshelf.getGreen() / 255.0f) * 100));
        }
    });
    mBluePicker.post(new Runnable() {
        @Override
        public void run() {
            mBluePicker.setProgress((int)((mBookshelf.getBlue() / 255.0f) * 100));
        }
    });
    mAmpPicker.post(new Runnable() {
        @Override
        public void run() {
            //范围是0~1
            mAmpPicker.setProgress((int) (mBookshelf.getAmpratio() * 100));
        }
    });
    mWavePicker.post(new Runnable() {
        @Override
        public void run() {
            mWavePicker.setProgress((int) (mBookshelf.getWaveratio() * 100));
        }
    });
    mCurrentPage.post(new Runnable() {
        @Override
        public void run() {
            mCurrentPage.setText(""+mBookshelf.getCurrentpage());
        }
    });
    mTotalPages.post(new Runnable() {
        @Override
        public void run() {
            mTotalPages.setText("of "+mBookshelf.getTotalpage());
        }
    });
    //mWaveLoadingView.setProgress(mBookshelf.getProgress());
    Log.e("此时progress是",mBookshelf.getProgress()+"");
    mWaveLoadingView.setTitletext(((int)(mBookshelf.getProgress() * 100)) + "" + " %");


}
 
源代码19 项目: ReadMark   文件: WaveLoadingViewHolder.java
private void initViews(){
    mContentView = LayoutInflater.from(mContext)
            .inflate(R.layout.item_wave_loading_view, mViewGroup, false);
    mWaveLoadingView = (WaveLoadingView) mContentView.findViewById(R.id.wave_loading_view);
    mWaveLoadingView.post(new Runnable() {
        @Override
        public void run() {
            mWaveLoadingView.setWaveColor(mBookshelf.getColor());
        }
    });
    mRedPicker = (SeekBar) mContentView.findViewById(R.id.red_picker);
    mGreenPicker = (SeekBar) mContentView.findViewById(R.id.green_picker);
    mBluePicker = (SeekBar) mContentView.findViewById(R.id.blue_picker);
    mAmpPicker = (SeekBar) mContentView.findViewById(R.id.amp_picker);
    mWavePicker = (SeekBar) mContentView.findViewById(R.id.wave_picker);
    mCurrentPage = (EditText) mContentView.findViewById(R.id.edit_current_page);
    mTotalPages = (TextView) mContentView.findViewById(R.id.text_total_page);
    mConfirmButton = (Button) mContentView.findViewById(R.id.button_confirm);
    //mCancelButton = (Button) mContentView.findViewById(R.id.button_cancel);


    mRedPicker.post(new Runnable() {
        @Override
        public void run() {
            mRedPicker.setProgress( (int)((mBookshelf.getRed() / 255.0f) * 100));
        }
    });
    mGreenPicker.post(new Runnable() {
        @Override
        public void run() {
            mGreenPicker.setProgress((int)((mBookshelf.getGreen() / 255.0f) * 100));
        }
    });
    mBluePicker.post(new Runnable() {
        @Override
        public void run() {
            mBluePicker.setProgress((int)((mBookshelf.getBlue() / 255.0f) * 100));
        }
    });
    mAmpPicker.post(new Runnable() {
        @Override
        public void run() {
            //范围是0~1
            mAmpPicker.setProgress((int) (mBookshelf.getAmpratio() * 100));
        }
    });
    mWavePicker.post(new Runnable() {
        @Override
        public void run() {
            mWavePicker.setProgress((int) (mBookshelf.getWaveratio() * 100));
        }
    });
    mCurrentPage.post(new Runnable() {
        @Override
        public void run() {
            mCurrentPage.setText(""+mBookshelf.getCurrentpage());
        }
    });
    mTotalPages.post(new Runnable() {
        @Override
        public void run() {
            mTotalPages.setText("of "+mBookshelf.getTotalpage());
        }
    });
    //mWaveLoadingView.setProgress(mBookshelf.getProgress());
    Log.e("此时progress是",mBookshelf.getProgress()+"");
    mWaveLoadingView.setTitletext(((int)(mBookshelf.getProgress() * 100)) + "" + " %");


}
 
@Override
protected void onCreate(Bundle arg0) {
    setTheme(App.theme.theme);
    super.onCreate(arg0);
    setContentView(R.layout.activity_file_editor);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Bundle b = getIntent().getExtras();
    if (b == null) {
        finish();
        return;
    }
    Picasso.with(this).load(b.<Uri>getParcelable(PreferencesFragment.ARG_ICON_URI)).error(R.drawable.ic_launcher).into((android.widget.ImageView) findViewById(android.R.id.home));

    mFile = b.getString(PreferencesFragment.ARG_FILE);
    mTitle = Utils.extractFileName(mFile);
    mPackageName = b.getString(PreferencesFragment.ARG_PACKAGE_NAME);
    mEditText = (EditText) findViewById(R.id.editText);
    //Hack to prevent EditText to request focus when the Activity is created
    mEditText.post(new Runnable() {
        @Override
        public void run() {
            mEditText.setFocusable(true);
            mEditText.setFocusableInTouchMode(true);
        }
    });

    if (arg0 == null) {
        mEditText.setText(Utils.readFile(mFile));
        mColorTheme = ColorThemeEnum.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString(KEY_COLOR_THEME, ColorThemeEnum.ECLIPSE.name()));
        setXmlFontSize(XmlFontSize.generateSize(PreferenceManager.getDefaultSharedPreferences(this).getInt(KEY_FONT_SIZE, XmlFontSize.MEDIUM.getSize())));
    } else {
        mHasContentChanged = arg0.getBoolean(KEY_HAS_CONTENT_CHANGED, false);
        mNeedUpdateOnActivityFinish = arg0.getBoolean(KEY_NEED_UPDATE_ON_ACTIVITY_FINISH, false);
        if (mNeedUpdateOnActivityFinish) {
            setResult(RESULT_OK);
        }
        mColorTheme = ColorThemeEnum.valueOf(arg0.getString(KEY_COLOR_THEME));
        setXmlFontSize(XmlFontSize.generateSize(arg0.getInt(KEY_FONT_SIZE)));
    }
    mXmlColorTheme = XmlColorTheme.createTheme(getResources(), mColorTheme);

    updateTitle();
    invalidateOptionsMenu();

    highlightXMLText(mEditText.getText());

    mEditText.clearFocus();
}