本文整理匯總了Java中android.widget.EditText.setInputType方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.setInputType方法的具體用法?Java EditText.setInputType怎麽用?Java EditText.setInputType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setInputType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hideSoftInput
import android.widget.EditText; //導入方法依賴的package包/類
/**
* 屏蔽輸入法, 對於當前輸入框(要進行深入的測試)
*
* @param activity
* @param editText
*/
@Deprecated
public static void hideSoftInput(Activity activity, EditText editText)
{
if (android.os.Build.VERSION.SDK_INT <= 100)
{
// 4.0
editText.setInputType(InputType.TYPE_NULL);
}
else
{
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
try
{
Class<EditText> cls = EditText.class;
Method setShowSoftInputOnFocus;
setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
setShowSoftInputOnFocus.setAccessible(true);
setShowSoftInputOnFocus.invoke(editText, false);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
示例2: showEditTextDialog
import android.widget.EditText; //導入方法依賴的package包/類
@SuppressLint("InflateParams")
public static AlertDialog showEditTextDialog(BaseActivity activity, String title, String content,
boolean isPassword, EditTextDialogCallback callback) {
View layout = LayoutInflater.from(activity).inflate(R.layout.view_dialog_edit_text, null);
EditText input = (EditText) layout.findViewById(R.id.edit_text);
input.setText(content);
if (isPassword) {
input.setInputType(InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
}
input.setSelection(input.getText().length());
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(title);
builder.setView(layout);
builder.setPositiveButton("確定", (dialog, which) -> {
if (callback != null) {
callback.onSuccess(input.getText().toString());
}
});
builder.setNegativeButton("取消", (dialog, which) -> dialog.dismiss());
return builder.show();
}
示例3: popup_getNumber_show
import android.widget.EditText; //導入方法依賴的package包/類
public void popup_getNumber_show(String popup_title, String popup_hint, DialogInterface.OnClickListener positiveOCL,DialogInterface.OnClickListener negativeOCL, String positiveText, String negativeText)
{
//by default, the pop up dialogue content is text input
//build popup dialogue
popUpWindow = new AlertDialog.Builder(context);
popUpWindow.setTitle(popup_title);
//set up the input field
popup_inputText = new EditText(context);
popup_inputText.setInputType(InputType.TYPE_CLASS_NUMBER);
popup_inputText.setHint(popup_hint); //set hint on what value the user should enter
popUpWindow.setView(popup_inputText);
//set up positive button
popUpWindow.setPositiveButton(positiveText, positiveOCL);
//set up negative button
popUpWindow.setNegativeButton(negativeText, negativeOCL);
popUpWindow.show();
}
示例4: inflateView
import android.widget.EditText; //導入方法依賴的package包/類
@Override
public View inflateView(LinearLayout layout, String value) {
editText = new EditText(context);
editText.setSingleLine();
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
if (value != null) {
editText.setText(value);
}
return inflater.new EditBuilder(layout, editText).withLabel(attribute.name).create();
}
示例5: onCreate
import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_config_sync);
volumeName = (EditText) findViewById(R.id.volumeName);
//volumeName.setFocusable(false);
volumePath = (EditText) findViewById(R.id.volumePath);
//volumePath.setFocusable(false);
password = (EditText) findViewById(R.id.volumePassword);
password.setTransformationMethod(PasswordTransformationMethod.getInstance());
password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
onlyWifiCheckBox = ((CheckBox) findViewById(R.id.onlyWifi));
removeAfterCheckBox = ((CheckBox) findViewById(R.id.removeAfter));
localFolder = ((EditText) findViewById(R.id.localFolder));
syncID = ((EditText) findViewById(R.id.syncID));
syncID.setFocusable(false);
spin1=(Spinner) findViewById(R.id.selectedRule);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(ConfigSyncActivity.this, android.R.layout.simple_spinner_item, rules);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin1.setAdapter(adapter);
spin1.setOnTouchListener(this);
spin1.setOnItemSelectedListener((OnItemSelectedListener) this);
refresh(null);
}
示例6: initView
import android.widget.EditText; //導入方法依賴的package包/類
private void initView() {
clearBtn = (Button) findViewById(R.id.btn_clear);
clearBtn.setOnClickListener(this);
serviceBtn = (Button) findViewById(R.id.btn_service);
serviceBtn.setOnClickListener(this);
bindAliasBtn = (Button) findViewById(R.id.btn_bind_alias);
bindAliasBtn.setOnClickListener(this);
unbindAliasBtn = (Button) findViewById(R.id.btn_unbind_alias);
unbindAliasBtn.setOnClickListener(this);
btnAddTag = (Button) findViewById(R.id.btnAddTag);
btnAddTag.setOnClickListener(this);
btnVersion = (Button) findViewById(R.id.btnVersion);
btnVersion.setOnClickListener(this);
btnSilentime = (Button) findViewById(R.id.btnSilentime);
btnSilentime.setOnClickListener(this);
btnGetCid = (Button) findViewById(R.id.btnGetCid);
btnGetCid.setOnClickListener(this);
tView = (TextView) findViewById(R.id.tvclientid);
appKeyView = (TextView) findViewById(R.id.tvappkey);
appSecretView = (TextView) findViewById(R.id.tvappsecret);
masterSecretView = (TextView) findViewById(R.id.tvmastersecret);
appIdView = (TextView) findViewById(R.id.tvappid);
tLogView = (EditText) findViewById(R.id.tvlog);
tLogView.setInputType(InputType.TYPE_NULL);
tLogView.setSingleLine(false);
tLogView.setHorizontallyScrolling(false);
transmissionBtn = (Button) findViewById(R.id.btn_pmsg);
transmissionBtn.setOnClickListener(this);
notifactionBtn = (Button) findViewById(R.id.btn_psmsg);
notifactionBtn.setOnClickListener(this);
}
示例7: createEditText
import android.widget.EditText; //導入方法依賴的package包/類
private EditText createEditText() {
LinearLayout.LayoutParams EditTextlayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
EditText editText = new EditText(getContext());
editText.setLayoutParams(EditTextlayoutParams);
editText.setHint(getString(R.string.answer, letters[inputLayout.getChildCount()]));
editText.setInputType(InputType.TYPE_CLASS_TEXT);
return editText;
}
示例8: showDialog
import android.widget.EditText; //導入方法依賴的package包/類
private void showDialog(List<EncdroidProviderParameter> questions){
if (questions==null || questions.size()==0) {
//if (activity instanceof Fillable){
try {
//this.init("/");*
finishFileProviderInit();
} catch (Exception e){
e.printStackTrace();
String exceptionLabel = e.getMessage();
if (exceptionLabel==null) exceptionLabel=e.toString();
Toast.makeText(this.getApplicationContext(),exceptionLabel, Toast.LENGTH_LONG).show();
//ask again parameters question to the user
if (instance.getParamsToAsk()!=null && instance.getParamsToAsk().size()>0){
this.showDialog( instance.getParamsToAsk());
}
return;
}
//}
//this.ready=true;
//((Fillable)activity).launchFillTask();
return;
}
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(questions.get(0).getTitle());
alert.setMessage(questions.get(0).getLabel());
// Set an EditText view to get user input
final EditText input = new EditText(this);
if (questions.get(0).isPassword()) {
input.setTransformationMethod(PasswordTransformationMethod.getInstance());
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
alert.setView(input);
alert.setPositiveButton("Ok", new ClickListener(this,instance,input,questions));
alert.show();
}
示例9: setupEditText
import android.widget.EditText; //導入方法依賴的package包/類
protected void setupEditText(EditText editText) {
editText.setInputType(InputType.TYPE_NULL);
editText.setFilters(filters);
editText.setOnTouchListener(touchListener);
editText.setTransformationMethod(PasswordTransformationMethod
.getInstance());
}
示例10: initFilenameInputDialog
import android.widget.EditText; //導入方法依賴的package包/類
public static void initFilenameInputDialog(MaterialDialog show) {
final EditText editText = show.getInputEditText();
editText.setSingleLine();
editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
// create an initial filename to suggest to the user
String filename = createLogFilename();
editText.setText(filename);
// highlight everything but the .txt at the end
editText.setSelection(0, filename.length() - 4);
}
示例11: onCreate
import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTitle("====== " + getString(R.string.config_polar_title) + " ======"); // title should not be too short, otherwise, dialog will be too narrow.
EditText edtXFrom = (EditText)findViewById(R.id.x_from_edit);
edtXFrom.setText("0");
edtXFrom.setEnabled(false);
EditText edtXTo = (EditText)findViewById(R.id.x_to_edit);
edtXTo.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
TextView tvXInputNote = (TextView)findViewById(R.id.x_input_note);
tvXInputNote.setText(getString(R.string.polar_chart_r_range_note));
TextView tvYInputNote = (TextView)findViewById(R.id.y_input_note);
tvYInputNote.setText(getString(R.string.polar_chart_angle_range_note) + " " + getString(R.string.degree) + ".");
}
示例12: popup_show
import android.widget.EditText; //導入方法依賴的package包/類
public void popup_show(String popup_title, String popup_hint, DialogInterface.OnClickListener clickListener)
{
//build popup dialogue
popUpWindow = new AlertDialog.Builder(context);
popUpWindow.setTitle(popup_title);
//set up the input field
popup_inputText = new EditText(context);
popup_inputText.setInputType(InputType.TYPE_CLASS_TEXT);
popup_inputText.setHint(popup_hint); //set hint on what value the user should enter
popUpWindow.setView(popup_inputText);
//set up positive button
popUpWindow.setPositiveButton("OK",clickListener);
//set up negative button
popUpWindow.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
dialogInterface.cancel();
}
});
popUpWindow.show();
}
示例13: setCardInput
import android.widget.EditText; //導入方法依賴的package包/類
public void setCardInput(Context context){
EditText input= ((EditText) findViewById(R.id.inputEdit));
input.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
input.setKeyListener(DigitsKeyListener.getInstance(context.getResources().getString(R.string.filter_vcode)));
}
示例14: EditTextCell
import android.widget.EditText; //導入方法依賴的package包/類
public EditTextCell(View itemView) {
super(itemView);
iv_icon = (ImageView) itemView.findViewById(R.id.iv_icon);
et_content = (EditText) itemView.findViewById(R.id.et_content);
et_content.setInputType(EditorInfo.TYPE_CLASS_TEXT);//默認 文字鍵盤
}
示例15: onCreate
import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(mResourceId);
try {
LinearLayout root = (LinearLayout) findViewById(R.id.easy_edit_dialog_root);
ViewGroup.LayoutParams params = root.getLayoutParams();
params.width = (int) ScreenUtil.getDialogWidth();
root.setLayoutParams(params);
if (mTitle != null) {
mTitleTextView = (TextView) findViewById(R.id.easy_dialog_title_text_view);
mTitleTextView.setText(mTitle);
}
if (mMessage != null) {
mMessageTextView = (TextView) findViewById(R.id.easy_dialog_message_text_view);
mMessageTextView.setText(mMessage);
mMessageTextView.setVisibility(View.VISIBLE);
}
mEdit = (EditText) findViewById(R.id.easy_alert_dialog_edit_text);
mLengthTextView = (TextView) findViewById(R.id.edit_text_length);
// mEdit.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxEditTextLength) });
mLengthTextView.setVisibility(mShowEditTextLength ? View.VISIBLE : View.GONE);
if (inputType != -1) {
mEdit.setInputType(inputType);
}
mEdit.addTextChangedListener(new EditTextWatcher(mEdit, mLengthTextView, mMaxEditTextLength,
mShowEditTextLength));
if (!TextUtils.isEmpty(mEditHint)) {
mEdit.setHint(mEditHint);
}
if (mMaxLines > 0) {
mEdit.setMaxLines(mMaxLines);
}
if (mSingleLine) {
mEdit.setSingleLine();
}
mPositiveBtn = (Button) findViewById(R.id.easy_dialog_positive_btn);
if (mPositiveBtnStrResId != 0) {
mPositiveBtn.setText(mPositiveBtnStrResId);
}
mPositiveBtn.setOnClickListener(mPositiveBtnListener);
mNegativeBtn = (Button) findViewById(R.id.easy_dialog_negative_btn);
if (mNegativeBtnStrResId != 0) {
mNegativeBtn.setText(mNegativeBtnStrResId);
}
mNegativeBtn.setOnClickListener(mNegativeBtnListener);
mNegativeBtn.setVisibility(View.VISIBLE);
findViewById(R.id.easy_dialog_btn_divide_view).setVisibility(View.VISIBLE);
} catch (Exception e) {
e.printStackTrace();
}
}